medianheap

Crates.iomedianheap
lib.rsmedianheap
version0.4.1
sourcesrc
created_at2018-12-02 06:02:47.148006
updated_at2024-01-13 01:02:59.871456
descriptionA median heap for keeping track of a running median.
homepagehttps://github.com/reitermarkus/medianheap-rs
repositoryhttps://github.com/reitermarkus/medianheap-rs
max_upload_size
id99631
size15,859
Markus Reiter (reitermarkus)

documentation

https://docs.rs/medianheap

README

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)));
Commit count: 47

cargo fmt