5 releases (3 breaking)

0.4.1 Jan 13, 2024
0.4.0 Jan 10, 2024
0.3.0 Mar 4, 2022
0.2.0 Jan 6, 2019
0.1.0 Dec 2, 2018

#764 in Data structures

Download history 14/week @ 2024-09-19 9/week @ 2024-09-26

58 downloads per month
Used in median-accumulator

MIT/Apache

15KB
289 lines

Median Heap

Crates.io Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
medianheap = "0.4"

Example

Elements of a MedianHeap must be Ord. If you want to create a MedianHeap containing floating point numbers, you can use the ordered-float crate.

let mut heap = MedianHeap::new();

assert_eq!(heap.median(), None);

heap.push(1);
assert_eq!(heap.median(), Some(Median::Single(&1)));

heap.push(3);
assert_eq!(heap.median(), Some(Median::Pair(&1, &3)));

lib.rs:

A median heap for keeping track of a running median.

Dependencies

~38KB