pub struct TimedList<T> { /* private fields */ }
Expand description
An iterable list structure where each element has an associated Duration
.
When an element’s Duration
has elapsed, the element is removed from the
list upon the next mutable function call. Timed-out elements will never be iterated over.
Implementations
sourceimpl<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 and 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 iter(&self) -> impl Iterator<Item = &T>
pub fn iter(&self) -> impl Iterator<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 atually iterated over.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<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 atually iterated over.
sourcepub fn timer_iter(&self) -> impl Iterator<Item = (&T, EggTimer)>
pub fn timer_iter(&self) -> impl Iterator<Item = (&T, EggTimer)>
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 atually iterated over.
sourcepub fn timer_iter_mut(&mut self) -> impl Iterator<Item = (&mut T, EggTimer)>
pub fn timer_iter_mut(&mut self) -> impl Iterator<Item = (&mut T, EggTimer)>
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 atually iterated over.
Trait Implementations
sourceimpl<T> IntoIterator for TimedList<T>where
T: 'static,
impl<T> IntoIterator for TimedList<T>where
T: 'static,
sourceimpl<T: PartialEq> PartialEq<TimedList<T>> for TimedList<T>
impl<T: PartialEq> PartialEq<TimedList<T>> for TimedList<T>
sourceimpl<T: PartialOrd> PartialOrd<TimedList<T>> for TimedList<T>
impl<T: PartialOrd> PartialOrd<TimedList<T>> for TimedList<T>
sourcefn partial_cmp(&self, other: &TimedList<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &TimedList<T>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more