### 2 unstable releases

0.2.0 | Jan 6, 2019 |
---|---|

0.1.0 | Dec 2, 2018 |

#**338** in Data structures

**17** downloads per month

**MIT/Apache**

16KB

322 lines

# Median Heap

## Usage

Add this to your

:`Cargo .toml`

`[``dependencies``]`
`medianheap ``=` `"`0.1`"`

and this to your crate root:

`extern` `crate` medianheap`;`

## Example

Elements of a

must be `MedianHeap`

.`Ord` `+` AverageWith `+` `Clone`

The

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 `AverageWith`

type from the `NotNan`

crate.`ordered-float`

`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

~186KB