sliding_window 0.1.2

A fixed size, heapless sliding window
Documentation
  • Coverage
  • 91.67%
    11 out of 12 items documented1 out of 12 items with examples
  • Size
  • Source code size: 14.18 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.97 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • bugadani/SlidingWindow
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bugadani

SlidingWindow crates.io

Sliding windows are used to hold the N most recent samples of a data stream.

Documentation

Example

use sliding_window::*;
use sliding_window::typenum::consts::*;

// Create a SlidingWindow with a window size of 4 elements
let mut sw: SlidingWindow<_, U4> = SlidingWindow::new();

// Insert some data
sw.insert(1);
sw.insert(2);
sw.insert(3);
sw.insert(4);

// The 0 index always returns the oldest element in the window
assert_eq!(1, sw[0]);

// When full, inserting a new element removes and returns the oldest
assert_eq!(Some(1), sw.insert(5));