pub struct DenseIdMap<K, V> { /* private fields */ }Expand description
A mapping from a NumericId to some value.
This mapping is dense: it stores a flat array indexed by K::index(),
with no hashing. For sparse mappings, use a HashMap.
Implementations§
Source§impl<K: NumericId, V> DenseIdMap<K, V>
impl<K: NumericId, V> DenseIdMap<K, V>
Sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create an empty map with space for n entries pre-allocated.
Sourcepub fn n_ids(&self) -> usize
pub fn n_ids(&self) -> usize
Get the number of ids currently indexed by the table (including “null” entries). This is a less useful version of “length” in other containers.
Sourcepub fn next_id(&self) -> K
pub fn next_id(&self) -> K
Get the key that would be returned by the next call to DenseIdMap::push.
Sourcepub fn push(&mut self, val: V) -> K
pub fn push(&mut self, val: V) -> K
Add the given mapping to the table, returning the key corresponding to
DenseIdMap::n_ids.
Sourcepub fn contains_key(&self, key: K) -> bool
pub fn contains_key(&self, key: K) -> bool
Test whether key is set in this map.
Sourcepub fn get_mut(&mut self, key: K) -> Option<&mut V>
pub fn get_mut(&mut self, key: K) -> Option<&mut V>
Get a mutable reference to the current mapping for key in the table.
Sourcepub fn unwrap_val(&mut self, key: K) -> V
pub fn unwrap_val(&mut self, key: K) -> V
Extract the value mapped to by key from the table.
§Panics
This method panics if key is not in the table.
Sourcepub fn take(&mut self, key: K) -> Option<V>
pub fn take(&mut self, key: K) -> Option<V>
Extract the value mapped to by key from the table, if it is present.
Sourcepub fn get_or_insert(&mut self, key: K, f: impl FnOnce() -> V) -> &mut V
pub fn get_or_insert(&mut self, key: K, f: impl FnOnce() -> V) -> &mut V
Get the current mapping for key in the table, or insert the value
returned by f and return a mutable reference to it.
pub fn raw(&self) -> &[Option<V>]
pub fn iter(&self) -> impl Iterator<Item = (K, &V)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (K, &mut V)>
Sourcepub fn reserve_space(&mut self, key: K)
pub fn reserve_space(&mut self, key: K)
Reserve space up to the given key in the table.
pub fn drain(&mut self) -> impl Iterator<Item = (K, V)> + '_
Source§impl<K: NumericId, V: Send + Sync> DenseIdMap<K, V>
impl<K: NumericId, V: Send + Sync> DenseIdMap<K, V>
Sourcepub fn par_iter(&self) -> impl ParallelIterator<Item = (K, &V)>
pub fn par_iter(&self) -> impl ParallelIterator<Item = (K, &V)>
Get a parallel iterator over the entries in the table.
Sourcepub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = (K, &mut V)>
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = (K, &mut V)>
Get a parallel iterator over mutable references to the entries in the table.
Source§impl<K: NumericId, V: Default> DenseIdMap<K, V>
impl<K: NumericId, V: Default> DenseIdMap<K, V>
pub fn get_or_default(&mut self, key: K) -> &mut V
Trait Implementations§
Source§impl<K: Clone, V: Clone> Clone for DenseIdMap<K, V>
impl<K: Clone, V: Clone> Clone for DenseIdMap<K, V>
Source§fn clone(&self) -> DenseIdMap<K, V>
fn clone(&self) -> DenseIdMap<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> Default for DenseIdMap<K, V>
impl<K, V> Default for DenseIdMap<K, V>
Source§impl<K: NumericId, V> Index<K> for DenseIdMap<K, V>
impl<K: NumericId, V> Index<K> for DenseIdMap<K, V>
Source§impl<K: NumericId, V> IndexMut<K> for DenseIdMap<K, V>
impl<K: NumericId, V> IndexMut<K> for DenseIdMap<K, V>
impl<K: Eq, V: Eq> Eq for DenseIdMap<K, V>
impl<K, V> StructuralPartialEq for DenseIdMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for DenseIdMap<K, V>
impl<K, V> RefUnwindSafe for DenseIdMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for DenseIdMap<K, V>
impl<K, V> Sync for DenseIdMap<K, V>
impl<K, V> Unpin for DenseIdMap<K, V>
impl<K, V> UnwindSafe for DenseIdMap<K, V>where
K: UnwindSafe,
V: 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§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