[][src]Struct sliding_window::SlidingWindow

pub struct SlidingWindow<IT, N> where
    N: Size<IT>, 
{ /* fields omitted */ }

A sliding window.

Sliding windows are queues that overwrite their oldest data when full.

Implementations

impl<IT, N> SlidingWindow<IT, N> where
    N: Size<IT>, 
[src]

pub fn new() -> Self[src]

Returns an empty sliding window object.

pub fn insert(&mut self, t: IT) -> Option<IT>[src]

Insert an element into the window.

If the window is full, this method will remove and return the oldest element.

pub fn clear(&mut self)[src]

Removes all elements from the window.

pub fn is_full(&self) -> bool[src]

Returns true if the window is full.

pub fn count(&self) -> usize[src]

Returns the number of elements stored in the window.

pub fn iter(&self) -> Iter<IT, N>[src]

Returns an iterator to read from the window.

The iterator starts at the oldest element and ends with the newest.

pub fn iter_unordered(&self) -> UnorderedIter<IT, N>[src]

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

impl<IT, N> Default for SlidingWindow<IT, N> where
    N: Size<IT>, 
[src]

impl<IT, N> Index<usize> for SlidingWindow<IT, N> where
    N: Size<IT>, 
[src]

type Output = IT

The returned type after indexing.

Auto Trait Implementations

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> where
    <N as ArrayLength<MaybeUninit<IT>>>::ArrayType: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.