pub struct Ring<const N: usize> { /* private fields */ }Expand description
A ring buffer holding up to N f64 values.
Implementations§
Source§impl<const N: usize> Ring<N>
impl<const N: usize> Ring<N>
Sourcepub fn push(&mut self, x: f64) -> Option<f64>
pub fn push(&mut self, x: f64) -> Option<f64>
Push x, overwriting the oldest slot once full.
Returns the evicted oldest value if the ring was already full, or None
while still filling. The caller (SMA) subtracts the returned value from
its rolling sum before adding x, matching the std subtract-then-add
order.
Sourcepub fn chrono_sum(&self) -> f64
pub fn chrono_sum(&self) -> f64
Sum the held values oldest-to-newest.
When full this walks buf[head..] then buf[..head] — the exact
chronological order (and thus the exact fold, starting from 0.0) that
wickra-core reseeds its rolling sum with, so the reseed is bit-for-bit
identical.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for Ring<N>
impl<const N: usize> RefUnwindSafe for Ring<N>
impl<const N: usize> Send for Ring<N>
impl<const N: usize> Sync for Ring<N>
impl<const N: usize> Unpin for Ring<N>
impl<const N: usize> UnsafeUnpin for Ring<N>
impl<const N: usize> UnwindSafe for Ring<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