#heap #priority-queue

min-max-heap

An efficient, double-ended priority queue

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

#123 in Data structures

Download history 483/week @ 2021-05-30 764/week @ 2021-06-06 429/week @ 2021-06-13 633/week @ 2021-06-20 327/week @ 2021-06-27 175/week @ 2021-07-04 467/week @ 2021-07-11 532/week @ 2021-07-18 571/week @ 2021-07-25 443/week @ 2021-08-01 300/week @ 2021-08-08 566/week @ 2021-08-15 661/week @ 2021-08-22 428/week @ 2021-08-29 324/week @ 2021-09-05 479/week @ 2021-09-12

1,772 downloads per month
Used in 9 crates (7 directly)

MIT/Apache

37KB
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

~205KB