Keep track of the minimum or maximum value in a sliding window.
moving min max
provides one data structure for keeping track of the
minimum value and one for keeping track of the maximum value in a sliding
window.
The algorithm is based on the description here.
The complexity of the operations are - O(1) for getting the minimum/maximum - O(1) for push - amortized O(1) for pop
```rust use movingminmax::MovingMin;
let mut movingmin = MovingMin::
asserteq!(movingmin.min(), Some(&1)); asserteq!(movingmin.pop(), Some(2));
asserteq!(movingmin.min(), Some(&1)); asserteq!(movingmin.pop(), Some(1));
asserteq!(movingmin.min(), Some(&1)); asserteq!(movingmin.pop(), Some(3));
asserteq!(movingmin.min(), None); asserteq!(movingmin.pop(), None); ```
or
```rust use movingminmax::MovingMax;
let mut movingmax = MovingMax::
asserteq!(movingmax.max(), Some(&3)); asserteq!(movingmax.pop(), Some(2));
asserteq!(movingmax.max(), Some(&3)); asserteq!(movingmax.pop(), Some(3));
asserteq!(movingmax.max(), Some(&3)); asserteq!(movingmax.pop(), Some(1));
asserteq!(movingmax.max(), None); asserteq!(movingmax.pop(), None); ```