binary-heap-plus2

Crates.iobinary-heap-plus2
lib.rsbinary-heap-plus2
version0.3.2
sourcesrc
created_at2020-09-21 23:37:39.071772
updated_at2020-09-22 02:04:54.911071
descriptionEnhanced version of std::collections::BinaryHeap that supports max, min, and custom-order heaps.
homepage
repositoryhttps://github.com/davidli2010/binary-heap-plus-rs
max_upload_size
id291351
size68,220
David  Li (davidli2010)

documentation

https://docs.rs/binary-heap-plus2/

README

binary-heap-plus2

Rust

This is a fork of binary-heap-plus, add a new generic constructor BinaryHeap::from_vec_cmp_rebuild().

binary-heap-plus is recommended if there are no special requirements.

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()
  • Min heap
    • Use BinaryHeap::new_min() or ::with_capacity_min()
  • Heap ordered by closure
    • Use BinaryHeap::new_by() or ::with_capacity_by()
  • Heap ordered by key generated by closure
    • Use BinaryHeap::new_by_key() or ::with_capacity_by_key()

Other notable added methods are:

  • BinaryHeap::from_vec_cmp(), BinaryHeap::from_vec() and BinaryHeap::from_vec_cmp_rebuild() for more generic construction.
  • .into_iter_sorted() which is less-surprising version of .into_iter(). The implementation is backported from std.

MSRV (Minimum Supported Rust Version)

This crate requires Rust 1.31.1 or later.

Changes

See CHANGELOG.md. https://github.com/sekineh/binary-heap-plus-rs/blob/master/CHANGELOG.md

Thanks

  • 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.

References

See the following discussions for the background of the crate:

Commit count: 112

cargo fmt