pub struct FixedSizeFlatMap<K: Eq, V: Clone, const CAPACITY: usize> { /* private fields */ }Expand description
A compile-time fixed-size, shared-memory compatible FixedSizeFlatMap.
Implementations§
Source§impl<K: Eq, V: Clone, const CAPACITY: usize> FixedSizeFlatMap<K, V, CAPACITY>
impl<K: Eq, V: Clone, const CAPACITY: usize> FixedSizeFlatMap<K, V, CAPACITY>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new FixedSizeFlatMap
Sourcepub fn insert(&mut self, id: K, value: V) -> Result<(), FlatMapError>
pub fn insert(&mut self, id: K, value: V) -> Result<(), FlatMapError>
Inserts a new key-value pair into the FixedSizeFlatMap. On success, the method returns Ok,
otherwise a FlatMapError describing the failure.
Sourcepub fn get(&self, id: &K) -> Option<V>
pub fn get(&self, id: &K) -> Option<V>
Returns a copy of the value corresponding to the given key. If there is no such key,
None is returned.
Sourcepub fn get_ref(&self, id: &K) -> Option<&V>
pub fn get_ref(&self, id: &K) -> Option<&V>
Returns a reference to the value corresponding to the given key. If there is no such
key, None is returned.
Sourcepub fn get_mut_ref(&mut self, id: &K) -> Option<&mut V>
pub fn get_mut_ref(&mut self, id: &K) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the given key. If there is
no such key, None is returned.
Sourcepub fn remove(&mut self, id: &K) -> Option<V>
pub fn remove(&mut self, id: &K) -> Option<V>
Removes a key (id) from the FixedSizeFlatMap, returning the Some(value) at the key
if the key was previously in the map or None otherwise.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the FixedSizeFlatMap is empty, otherwise false.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true if the FixedSizeFlatMap is full, otherwise false.
Sourcepub fn contains(&self, id: &K) -> bool
pub fn contains(&self, id: &K) -> bool
Returns true if the FixedSizeFlatMap contains the given key, otherwise false.
Sourcepub fn list_keys<F: FnMut(&K) -> CallbackProgression>(&self, callback: F)
pub fn list_keys<F: FnMut(&K) -> CallbackProgression>(&self, callback: F)
Iterates over all keys of the map and calls the provided callback.
Trait Implementations§
Source§impl<K: Eq + Debug, V: Clone + Debug, const CAPACITY: usize> Debug for FixedSizeFlatMap<K, V, CAPACITY>
impl<K: Eq + Debug, V: Clone + Debug, const CAPACITY: usize> Debug for FixedSizeFlatMap<K, V, CAPACITY>
Source§impl<K: Eq, V: Clone, const CAPACITY: usize> PlacementDefault for FixedSizeFlatMap<K, V, CAPACITY>
impl<K: Eq, V: Clone, const CAPACITY: usize> PlacementDefault for FixedSizeFlatMap<K, V, CAPACITY>
Source§unsafe fn placement_default(ptr: *mut Self)
unsafe fn placement_default(ptr: *mut Self)
Default::default(). Read more