binary-heap-plus-rs
Enhancement over Rust's std::collections::BinaryHeap.
This crate requires Rust 1.26 or later.
It is a prototype that implements the following variations in a backward-compatible way.
- The suffix
_minrefers to min heap. - The suffix
_byand_by_keyare analogous tosort_byandsort_by_key.
::new_xxx()
::new()// creates a max heap::new_min()// creates a min heap::new_by(f)// creates a heap ordered by the given closuref::new_by_key(g)// creates a heap ordered by key generated by the given closureg
::with_capacity_xxx()
::with_capacity(n)// creates a max heap with capacityn::with_capacity_min(n)// creates a min heap with capacityn::with_capacity_by(n, f)// creates a heap with capacityn, ordered by the given closuref::with_capacity_by_key(n, g)// creates a heap with capacityn, ordered by key generated by the given closureg
Future
In future, the trait Compare<T> might be replaced with FnMut(&T, &T) -> Ordering.
To do that, rustc needs to stabilize a few unstable features.
References
See the following discussions for the background: