Struct e_ring::Ring[][src]

pub struct Ring<T, const N: usize> { /* fields omitted */ }

Append only data structure, replace oldest element when reach maximum capacity of N elements

Implementations

impl<T: Copy + Default + PartialOrd + Sub<Output = T> + Add<Output = T> + Mul<Output = T> + Div<Output = T> + Into<f32>, const N: usize> Ring<T, N>[src]

pub fn avg(&self) -> f32[src]

Calculate the average of the elements in the Ring

pub fn var(&self, avg: Option<f32>) -> f32[src]

Calculate the variance of the elements in the Ring, use provided avg if Some, otherwise it calculates it (in the latter case two iterations are required).

impl<T: Copy + Default + PartialOrd + Sub<Output = T> + Add<Output = T> + Mul<Output = T> + Div<Output = T> + Into<f32>, const N: usize> Ring<T, N>[src]

pub fn rescaled_iter(
    &self,
    current: Range<T>,
    desired: Range<T>
) -> RescaleIterator<'_, T, N>
[src]

Returns an iterator over the Ring on which values are rescaled according to the desired range

impl<T: Copy + Default, const N: usize> Ring<T, N>[src]

pub fn new() -> Self[src]

Creates a new Ring of give size N

pub fn append(&mut self, el: T)[src]

Append an element to the Ring, if there are already N elements, it replaces the oldest.

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

Number of elements in the Ring, it never decreases.

pub fn iter(&self) -> RingIterator<'_, T, N>[src]

Returns an iterator over the Ring starting from the oldest appended element

Trait Implementations

impl<T: Debug, const N: usize> Debug for Ring<T, N>[src]

impl<T: PartialOrd + Copy + Default, const N: usize> FindRange<T> for Ring<T, N>[src]

Auto Trait Implementations

impl<T, const N: usize> Send for Ring<T, N> where
    T: Send

impl<T, const N: usize> Sync for Ring<T, N> where
    T: Sync

impl<T, const N: usize> Unpin for Ring<T, N> where
    T: 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, 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.