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

#323 in Data structures

Download history 22163/week @ 2024-08-16 22084/week @ 2024-08-23 14819/week @ 2024-08-30 15421/week @ 2024-09-06 9424/week @ 2024-09-13 10990/week @ 2024-09-20 13221/week @ 2024-09-27 15581/week @ 2024-10-04 18637/week @ 2024-10-11 18694/week @ 2024-10-18 20041/week @ 2024-10-25 20197/week @ 2024-11-01 19393/week @ 2024-11-08 18125/week @ 2024-11-15 16475/week @ 2024-11-22 17194/week @ 2024-11-29

74,995 downloads per month
Used in 61 crates (12 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