pub struct TimedList<T> { /* private fields */ }Expand description
Implementations§
Source§impl<T> TimedList<T>
impl<T> TimedList<T>
Sourcepub fn insert<D: ToDuration>(&mut self, element: T, time: D)
pub fn insert<D: ToDuration>(&mut self, element: T, time: D)
Inserts an element into the list with the given number of floating-point seconds
Sourcepub fn clean(&mut self)
pub fn clean(&mut self)
Forces the removal of all elements whose Duration has elpased.
This method does not need to be called manually unless you
want to explicitely free the memory of timed-out elements immediately.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the list is empty or if all existing elements have timed out.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = &T>
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &T>
Iterates immutably through all elements.
While this method does not remove timed-out elements, it does filter them out. If iteration takes sufficiently long, elements that may have been valid when iteration began may be skipped when they are actually iterated over.
Sourcepub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut T>
Iterates mutably through all elements.
If iteration takes sufficiently long, elements that may have been valid when iteration began may be skipped when they are actually iterated over.
Sourcepub fn timer_iter(&self) -> impl DoubleEndedIterator<Item = (&T, Timer)>
pub fn timer_iter(&self) -> impl DoubleEndedIterator<Item = (&T, Timer)>
Iterates immutably through all elements and their timers.
While this method does not remove timed-out elements, it does filter them out. If iteration takes sufficiently long, elements that may have been valid when iteration began may be skipped when they are actually iterated over.
Sourcepub fn timer_iter_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = (&mut T, Timer)>
pub fn timer_iter_mut( &mut self, ) -> impl DoubleEndedIterator<Item = (&mut T, Timer)>
Iterates mutably through all elements.
If iteration takes sufficiently long, elements that may have been valid when iteration began may be skipped when they are actually iterated over.