pub struct MovingMax<T> { /* private fields */ }
Expand description
Keep track of the maximum value in a sliding window.
See MovingMin
for more details.
let mut moving_max = MovingMax::<i32>::new();
moving_max.push(2);
moving_max.push(3);
moving_max.push(1);
assert_eq!(moving_max.max(), Some(&3));
assert_eq!(moving_max.pop(), Some(2));
assert_eq!(moving_max.max(), Some(&3));
assert_eq!(moving_max.pop(), Some(3));
assert_eq!(moving_max.max(), Some(&1));
assert_eq!(moving_max.pop(), Some(1));
assert_eq!(moving_max.max(), None);
assert_eq!(moving_max.pop(), None);
Implementations§
Source§impl<T: Clone + PartialOrd> MovingMax<T>
impl<T: Clone + PartialOrd> MovingMax<T>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for MovingMax<T>
impl<T> RefUnwindSafe for MovingMax<T>where
T: RefUnwindSafe,
impl<T> Send for MovingMax<T>where
T: Send,
impl<T> Sync for MovingMax<T>where
T: Sync,
impl<T> Unpin for MovingMax<T>where
T: Unpin,
impl<T> UnwindSafe for MovingMax<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more