pub struct SlidingWindow<IT, N>where
N: Size<IT>,{ /* private fields */ }
Expand description
A sliding window.
Sliding windows are queues that overwrite their oldest data when full.
Implementations§
Source§impl<IT, N> SlidingWindow<IT, N>where
N: Size<IT>,
impl<IT, N> SlidingWindow<IT, N>where
N: Size<IT>,
Sourcepub fn insert(&mut self, t: IT) -> Option<IT>
pub fn insert(&mut self, t: IT) -> Option<IT>
Insert an element into the window.
If the window is full, this method will remove and return the oldest element.
Sourcepub fn iter(&self) -> Iter<'_, IT, N> ⓘ
pub fn iter(&self) -> Iter<'_, IT, N> ⓘ
Returns an iterator to read from the window.
The iterator starts at the oldest element and ends with the newest.
Sourcepub fn iter_unordered(&self) -> UnorderedIter<'_, IT, N> ⓘ
pub fn iter_unordered(&self) -> UnorderedIter<'_, IT, N> ⓘ
Returns an iterator to read from the window.
This iterator starts at the beginning of the internal array instead of the oldest element so it does not return the elements in the order of insertion.
Trait Implementations§
Source§impl<IT, N> Default for SlidingWindow<IT, N>where
N: Size<IT>,
impl<IT, N> Default for SlidingWindow<IT, N>where
N: Size<IT>,
Auto Trait Implementations§
impl<IT, N> Freeze for SlidingWindow<IT, N>
impl<IT, N> RefUnwindSafe for SlidingWindow<IT, N>
impl<IT, N> Send for SlidingWindow<IT, N>where
IT: Send,
impl<IT, N> Sync for SlidingWindow<IT, N>where
IT: Sync,
impl<IT, N> Unpin for SlidingWindow<IT, N>
impl<IT, N> UnwindSafe for SlidingWindow<IT, N>
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