Enhancement over Rust's std::collections::BinaryHeap
.
It supports the following heaps and still maintains backward compatibility.
- Max heap
- Use
BinaryHeap::new()
or::with_capacity()
- Use
- Min heap
- Use
BinaryHeap::new_min()
or::with_capacity_min()
- Use
- Heap ordered by closure
- Use
BinaryHeap::new_by()
or::with_capacity_by()
- Use
- Heap ordered by key generated by closure
- Use
BinaryHeap::new_by_key()
or::with_capacity_by_key()
- Use
Other notable added methods are:
BinaryHeap::from_vec_cmp()
andBinaryHeap::from_vec()
for more generic construction..into_iter_sorted()
which is less-surprising version of.into_iter()
. The implementation is backported fromstd
..replace_cmp()
which replace the comparator of the existing heap.
This crate requires Rust 1.32.0 or later.
See CHANGELOG.md. https://github.com/sekineh/binary-heap-plus-rs/blob/master/CHANGELOG.md
- I received many valuable feedback from Pre-RFC thread [1].
- The current design is based on @ExpHP's suggestion that compiles on stable compiler.
- DDOtten, steven099, CAD97, ExpHP, scottmcm, Nemo157 and gnzlbg, thanks for looking into the design!
- @ulysseB sent me a first pull request!
- @inesseq contributed feature
serde1
. - @davidli2010 contributed comparator update and
unsafe
perf optimazation.
See the following discussions for the background of the crate: