pub struct Window<T> { /* private fields */ }Expand description
The Window struct is used internally and is of interest primarily to developers creating a new statistics type.
A Window instance maintains a set of items of type T. The set size is limited to a configurable parameter. The oldest item is dropped when a new item is entered and the window is full.
Implementations§
Source§impl<T> Window<T>
impl<T> Window<T>
Sourcepub fn new(size_limit: usize, live_limit: usize) -> Window<T>
pub fn new(size_limit: usize, live_limit: usize) -> Window<T>
Constructs a new window instance.
pub fn is_empty(&self) -> bool
Sourcepub fn newest_mut(&mut self) -> Option<&mut T>
pub fn newest_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the current instance.
Sourcepub fn index_all(&self, index: usize) -> Option<&T>
pub fn index_all(&self, index: usize) -> Option<&T>
Returns a pointer to a given element in the window. The array is indexed with element zero being the oldest.
Sourcepub fn index_live(&self, index: usize) -> Option<&T>
pub fn index_live(&self, index: usize) -> Option<&T>
Returns a pointer to a live element. The items are ordered by age wth the oldest at index 0.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Deletes all data from the window. This puts it back into its initial state.
Sourcepub fn iter_all(&self) -> WindowIterator<'_, T> ⓘ
pub fn iter_all(&self) -> WindowIterator<'_, T> ⓘ
Iterates over all the items in the window.
Sourcepub fn iter_live(&self) -> WindowIterator<'_, T> ⓘ
pub fn iter_live(&self) -> WindowIterator<'_, T> ⓘ
Iterates over all the live items in the window.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Window<T>
impl<T> RefUnwindSafe for Window<T>where
T: RefUnwindSafe,
impl<T> Send for Window<T>where
T: Send,
impl<T> Sync for Window<T>where
T: Sync,
impl<T> Unpin for Window<T>where
T: Unpin,
impl<T> UnwindSafe for Window<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