1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Collectors for [`BinaryHeap`]
//!
//! This module corresponds to [`std::collections::binary_heap`].
//!
//! # Notes
//!
//! You generally should **not** use `BinaryHeap::new().into_collector()`
//! to construct a new `BinaryHeap`, since the time complexity is `O(n log n)`,
//! which can be less efficient than constructing a [`Vec`] then converting to
//! a `BinaryHeap` (`O(n)`).
//!
//! Do the following instead to construct a [`BinaryHeap`] from scratch:
//!
//! ```
//! use std::collections::BinaryHeap;
//! use better_collect::prelude::*;
//!
//! let mut collector = vec![]
//! .into_collector()
//! .map_output(BinaryHeap::from);
//! #
//! # collector.collect(1);
//! ```
use BinaryHeap;
use BinaryHeap;
/// A collector that pushes collected items into a [`BinaryHeap`].
/// Its [`Output`] is [`BinaryHeap`].
///
/// This struct is created by `BinaryHeap::into_collector()`.
///
/// [`Output`]: crate::collector::CollectorBase::Output
);
/// A collector that pushes collected items into a [`&mut BinaryHeap`](BinaryHeap).
/// Its [`Output`] is [`&mut BinaryHeap`](BinaryHeap).
///
/// This struct is created by `BinaryHeap::collector_mut()`.
///
/// [`Output`]: crate::collector::CollectorBase::Output
&'a mut );