# rolling-median
[](https://crates.io/crates/rolling-median)
[](https://crates.io/crates/rolling-median)
[](https://crates.io/crates/rolling-median/versions)
[](https://docs.rs/rolling-median/latest/)
[](https://opensource.org/license/0BSD)
Computes the [**median**](https://en.wikipedia.org/wiki/Median) of a data set, using a "rolling" (online) algorithm.
## Complexity
The `push()` operation has a complexity of: **`O(log(n))`**
The `get()` operation has a complexity of: **`O(1)`**
## Installation
In order to use this crate, add it to `[dependencies]` in your **`Cargo.toml`**:
```
[dependencies]
rolling-median = "1.5.5"
```
## Usage
Here is a simple example that demonstrates how to use it:
```rust
use rolling_median::Median;
fn main() {
let mut rolling_median = Median::new();
while let Some(value) = get_data() {
rolling_median.push(value);
println!("Median, so far: {:?}", rolling_median.get())
}
println!("Final median: {:?}", rolling_median.get())
}
fn get_data() -> Option<f64> { /* ... */ }
```
## License
This software is released under the BSD Zero Clause (“0BSD”) License.
Copyright (C) 2025-2026 by LoRd_MuldeR <mulder2@gmx.de>.