Struct dfir_rs::util::monotonic_map::MonotonicMap
source · pub struct MonotonicMap<K, V>where
K: PartialOrd,{ /* private fields */ }Expand description
A map-like interface which in reality only stores one value at a time.
The keys must be monotonically increasing (i.e. timestamps). For Hydroflow, this allows state
to be stored which resets each tick by using the tick counter as the key. In the generic Map
case it can be swapped out for a true map to allow processing of multiple ticks of data at
once.
Implementations§
source§impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
sourcepub fn new_init(val: V) -> Self
pub fn new_init(val: V) -> Self
Creates a new MonotonicMap initialized with the given value. The
vaue will be Cleared before it is accessed.
sourcepub fn get_mut_with(&mut self, key: K, init: impl FnOnce() -> V) -> &mut V
pub fn get_mut_with(&mut self, key: K, init: impl FnOnce() -> V) -> &mut V
Inserts the value using the function if new key is strictly later than the current key.
source§impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
V: Default,
impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
V: Default,
sourcepub fn get_mut_default(&mut self, key: K) -> &mut V
pub fn get_mut_default(&mut self, key: K) -> &mut V
Gets a mutable reference to the inner value. If key is strictly later than the existing
key, the value will be reset to Default::default.
source§impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
V: Clear,
impl<K, V> MonotonicMap<K, V>where
K: PartialOrd,
V: Clear,
sourcepub fn get_mut_clear(&mut self, key: K) -> &mut V
pub fn get_mut_clear(&mut self, key: K) -> &mut V
Gets a mutable reference to the inner value. If key is strictly later than the existing
key, the value will be cleared via the Clear trait.
Trait Implementations§
source§impl<K, V: Clone> Clone for MonotonicMap<K, V>where
K: PartialOrd + Clone,
impl<K, V: Clone> Clone for MonotonicMap<K, V>where
K: PartialOrd + Clone,
source§fn clone(&self) -> MonotonicMap<K, V>
fn clone(&self) -> MonotonicMap<K, V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<K, V: Debug> Debug for MonotonicMap<K, V>where
K: PartialOrd + Debug,
impl<K, V: Debug> Debug for MonotonicMap<K, V>where
K: PartialOrd + Debug,
source§impl<K, V> Default for MonotonicMap<K, V>where
K: PartialOrd,
V: Default,
impl<K, V> Default for MonotonicMap<K, V>where
K: PartialOrd,
V: Default,
Auto Trait Implementations§
impl<K, V> Freeze for MonotonicMap<K, V>
impl<K, V> RefUnwindSafe for MonotonicMap<K, V>where
V: RefUnwindSafe,
K: RefUnwindSafe,
impl<K, V> Send for MonotonicMap<K, V>
impl<K, V> Sync for MonotonicMap<K, V>
impl<K, V> Unpin for MonotonicMap<K, V>
impl<K, V> UnwindSafe for MonotonicMap<K, V>where
V: UnwindSafe,
K: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more