pub struct TimeWindow<T> { /* private fields */ }
Available on crate feature
std
only.Expand description
This struct is a rolling time window for the provided data. It will automatically “throw out” data that falls outside (older) than the most recent data provided. It does NOT do any downsampling or processing of the data.
Implementations§
Source§impl<T: Copy> TimeWindow<T>
impl<T: Copy> TimeWindow<T>
pub fn new(window_duration: Duration) -> Self
pub fn insert(&mut self, timestamp: Timestamp<T>, value: f64)
pub fn clear(&mut self)
pub fn add_sample(&mut self, samp: Sample<T>)
Sourcepub fn first_key_value(&self) -> Option<(&Timestamp<T>, &f64)>
pub fn first_key_value(&self) -> Option<(&Timestamp<T>, &f64)>
returns the first (earliest, oldest) sample provided
Sourcepub fn last_key_value(&self) -> Option<(&Timestamp<T>, &f64)>
pub fn last_key_value(&self) -> Option<(&Timestamp<T>, &f64)>
returns the last (latest, newest) sample provided
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> impl Iterator<Item = (&Timestamp<T>, &f64)> + Clone
pub fn map_data<V, F: Fn((&Timestamp<T>, &f64)) -> V>(&self, fun: F) -> Vec<V>
Auto Trait Implementations§
impl<T> Freeze for TimeWindow<T>
impl<T> RefUnwindSafe for TimeWindow<T>where
T: RefUnwindSafe,
impl<T> Send for TimeWindow<T>where
T: Send,
impl<T> Sync for TimeWindow<T>where
T: Sync,
impl<T> Unpin for TimeWindow<T>
impl<T> UnwindSafe for TimeWindow<T>where
T: RefUnwindSafe,
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