pub struct RingBuffer<T: DataPoint + Copy, const N: usize> { /* private fields */ }Expand description
High-performance ring buffer optimized for real-time data
Implementations§
Source§impl<T: DataPoint + Copy, const N: usize> RingBuffer<T, N>
impl<T: DataPoint + Copy, const N: usize> RingBuffer<T, N>
Sourcepub fn with_config(config: RingBufferConfig) -> Self
pub fn with_config(config: RingBufferConfig) -> Self
Create a new ring buffer with custom configuration
Sourcepub fn set_event_handler(&mut self, handler: fn(RingBufferEvent))
pub fn set_event_handler(&mut self, handler: fn(RingBufferEvent))
Set event handler for notifications
Sourcepub fn push(&mut self, value: T) -> ChartResult<()>
pub fn push(&mut self, value: T) -> ChartResult<()>
Push a new value into the ring buffer
Sourcepub fn extend<I>(&mut self, iter: I) -> ChartResult<usize>where
I: IntoIterator<Item = T>,
pub fn extend<I>(&mut self, iter: I) -> ChartResult<usize>where
I: IntoIterator<Item = T>,
Push multiple values efficiently
Sourcepub fn peek_newest(&self) -> Option<&T>
pub fn peek_newest(&self) -> Option<&T>
Peek at the newest value without removing it
Sourcepub fn iter_chronological(&self) -> ChronologicalIter<'_, T, N> ⓘ
pub fn iter_chronological(&self) -> ChronologicalIter<'_, T, N> ⓘ
Get an iterator over all values in chronological order (oldest to newest) This properly handles the wrap-around case when the buffer is full
Sourcepub fn recent(&self, n: usize) -> impl Iterator<Item = &T>
pub fn recent(&self, n: usize) -> impl Iterator<Item = &T>
Get a slice of the most recent n values
Sourcepub fn remaining_capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
Get remaining capacity
Sourcepub fn bounds(&self) -> Option<DataBounds<f32, f32>>
pub fn bounds(&self) -> Option<DataBounds<f32, f32>>
Get current bounds (if tracking is enabled and T is Point2D)
Sourcepub fn stats(&self) -> &RingBufferStats
pub fn stats(&self) -> &RingBufferStats
Get performance statistics
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset performance statistics
Source§impl<const N: usize> RingBuffer<Point2D, N>
impl<const N: usize> RingBuffer<Point2D, N>
Sourcepub fn push_point(&mut self, point: Point2D) -> ChartResult<()>
pub fn push_point(&mut self, point: Point2D) -> ChartResult<()>
Push a Point2D with bounds tracking
Sourcepub fn moving_average(&self, window_size: usize) -> Option<Point2D>
pub fn moving_average(&self, window_size: usize) -> Option<Point2D>
Calculate moving average over the last n points
Sourcepub fn downsample(&self, factor: usize) -> Vec<Point2D, N>
pub fn downsample(&self, factor: usize) -> Vec<Point2D, N>
Downsample data by taking every nth point
Sourcepub fn rate_of_change(&self) -> Option<f32>
pub fn rate_of_change(&self) -> Option<f32>
Get the rate of change between the newest and oldest points