min-max-heap: a double-ended priority queue
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
It’s on crates.io, so add this to your
[dependencies] min-max-heap = "1.3.0"
This crate supports Rust version 1.32.0 and later.
My reference for a min-max heap is here. Much of this code is also based on
BinaryHeap from the standard library.