Skip to content

sekineh/binary-heap-plus-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

binary-heap-plus-rs

Rust

Enhancement over Rust's std::collections::BinaryHeap.

It supports the following features and still maintains backward compatibility.

  • Max heap
  • Min heap
  • Heap ordered by closure
  • Heap ordered by key generated by closure

Notable added method is:

  • .into_iter_sorted() backported from std.

MSRV (Minimum Supported Rust Version)

This crate requires Rust 1.31.1 or later.

Note on BinaryHeap::from_vec()

Currently, the From<Vec<T>> trait is implemented for max heap only. If you add generic impl for other heaps, the existing code breaks, requires slight modification such as type annotation.

To maintain good compatibility with std version, ::from_vec() method was added for the same purpose.

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:

About

Enhancement over Rust's `std::collections::BinaryHeap`. Supports other than max heap.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages