16 releases (stable)

1.3.0 Dec 30, 2019
1.2.2 Dec 17, 2018
1.2.0 Jun 2, 2018
1.1.1 May 30, 2018
0.1.2 Jun 13, 2016

#218 in Data structures

Download history 24286/week @ 2024-07-24 23710/week @ 2024-07-31 23450/week @ 2024-08-07 21517/week @ 2024-08-14 22569/week @ 2024-08-21 15559/week @ 2024-08-28 17808/week @ 2024-09-04 11986/week @ 2024-09-11 7419/week @ 2024-09-18 14779/week @ 2024-09-25 15107/week @ 2024-10-02 16549/week @ 2024-10-09 18307/week @ 2024-10-16 20179/week @ 2024-10-23 19647/week @ 2024-10-30 18010/week @ 2024-11-06

81,469 downloads per month
Used in 59 crates (11 directly)

MIT/Apache

38KB
902 lines

min-max-heap: a double-ended priority queue

Build Status Crates.io License: MIT License: Apache 2.0

A min-max-heap is like a binary heap, but it allows extracting both the minimum and maximum value efficiently. In particular, finding either the minimum or maximum element is O(1). A removal of either extremum, or an insertion, is O(log n).

Usage

It’s on crates.io, so add this to your Cargo.toml:

[dependencies]
min-max-heap = "1.3.0"

This crate supports Rust version 1.32.0 and later.

References

My reference for a min-max heap is here. Much of this code is also based on BinaryHeap from the standard library.

Dependencies

~160KB