#median #heap

medianheap

A median heap for keeping track of a running median

2 unstable releases

0.2.0 Jan 6, 2019
0.1.0 Dec 2, 2018

#3 in #median

Download history 9/week @ 2018-12-03 12/week @ 2018-12-10 1/week @ 2018-12-17 8/week @ 2018-12-24 1/week @ 2018-12-31 13/week @ 2019-01-07 7/week @ 2019-01-14 5/week @ 2019-01-21 1/week @ 2019-01-28

17 downloads per month

MIT/Apache

16KB
322 lines

Median Heap

Build Status Crates.io Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
medianheap = "0.1"

and this to your crate root:

extern crate medianheap;

Example

Elements of a MedianHeap must be Ord + AverageWith + Clone.

The AverageWith trait is used to calculate the mean value for the two middlemost items if the number of items is even. This is implemented for all integer types and the NotNan type from the ordered-float crate.

let mut heap = MedianHeap::new();

heap.push(1);

assert_eq!(heap.median(), Some(1));

heap.push(3);

assert_eq!(heap.median(), Some(2));

lib.rs:

A median heap for keeping track of a running median.

Dependencies

~54KB