rolling-median 1.0.0

Compute the median using a 'rolling' (online) algorithm
Documentation

rolling-median

no_std Crates.io Downloads Release Date Docs.rs License

Computes the median of a data set, using a "rolling" (online) algorithm.

Complexity:

The push() opreration has a complexity of: O(log(n))

The get() opreration has a complexity of: O(1)

Installation

In order to use this crate, add it under [dependencies] to your Cargo.toml:

[dependencies]
rolling-median = "1.0.0"

Usage

Here is a simple example that demonstrates how to use it:

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::<f64>())
    }

    println!("Final median: {:?}", rolling_median.get::<f64>())
}

fn get_data() -> Option<u32> { /* ... */ }

License

This software is released under the BSD Zero Clause (“0BSD”) License.

Copyright (C) 2025 by LoRd_MuldeR <mulder2@gmx.de>.