Struct e_ring::Ring [−][src]
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]
&self,
current: Range<T>,
desired: Range<T>
) -> RescaleIterator<'_, T, N>
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,
T: Send,
impl<T, const N: usize> Sync for Ring<T, N> where
T: Sync,
T: Sync,
impl<T, const N: usize> Unpin for Ring<T, N> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,