pub struct UnmanagedDenseMap<K, V> { /* private fields */ }Expand description
A dense map from keys to values with default fallbacks.
Implementations§
Source§impl<K, V> UnmanagedDenseMap<K, V>
impl<K, V> UnmanagedDenseMap<K, V>
Sourcepub fn new() -> Selfwhere
V: Default,
pub fn new() -> Selfwhere
V: Default,
Creates a new secondary map.
This does not allocate any memory until a value is modified.
Sourcepub const fn with_default(default: V) -> Self
pub const fn with_default(default: V) -> Self
Creates a new secondary map, specifying the default element.
This does not allocate any memory until a value is modified.
Sourcepub fn with_capacity(capacity: usize) -> Selfwhere
V: Default,
pub fn with_capacity(capacity: usize) -> Selfwhere
V: Default,
Creates a new secondary map with specified capacity.
Sourcepub fn with_capacity_and_default(capacity: usize, default: V) -> Self
pub fn with_capacity_and_default(capacity: usize, default: V) -> Self
Creates a new secondary map with specified capacity and default element.
Sourcepub fn ensure_capacity(&mut self, capacity: usize)
pub fn ensure_capacity(&mut self, capacity: usize)
Increases the capacity of the secondary map to capacity.
Does nothing when the capacity of the secondary map is already sufficient.
Sourcepub fn shrink_to(&mut self, capacity: usize)
pub fn shrink_to(&mut self, capacity: usize)
Reduces the capacity of the secondary map to capacity.
Stored values higher than capacity are dropped.
Does nothing when the capacity of the secondary map is already lower.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the maximum index the secondary map can contain without allocating.
Sourcepub fn rekey(&mut self, old: K, new: Option<K>)where
V: Default,
pub fn rekey(&mut self, old: K, new: Option<K>)where
V: Default,
Remove key old and optionally move to key new.
This method is useful for rekey callbacks such as in
PortMut::set_num_ports and PortMut::compact_nodes.
Sourcepub fn get(&self, key: K) -> &V
pub fn get(&self, key: K) -> &V
Immutably borrows the value at a key.
Returns a borrow of the default value when no value has been set for the key.
Sourcepub fn get_mut(&mut self, key: K) -> &mut V
pub fn get_mut(&mut self, key: K) -> &mut V
Mutably borrows the value at a key.
When the value is not present, the secondary map is resized to accommodate it.
To avoid frequent resizing, use SecondaryMap::ensure_capacity to keep the
capacity of the secondary map in line with the size of the key space.
Sourcepub fn try_get_mut(&mut self, key: K) -> Option<&mut V>
pub fn try_get_mut(&mut self, key: K) -> Option<&mut V>
Mutably borrows the value at a key.
Returns None when the key is beyond the capacity of the secondary map.
Trait Implementations§
Source§impl<K: Clone, V: Clone> Clone for UnmanagedDenseMap<K, V>
impl<K: Clone, V: Clone> Clone for UnmanagedDenseMap<K, V>
Source§fn clone(&self) -> UnmanagedDenseMap<K, V>
fn clone(&self) -> UnmanagedDenseMap<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 UnmanagedDenseMap<K, V>
impl<K, V> Default for UnmanagedDenseMap<K, V>
Source§impl<K, V> Index<K> for UnmanagedDenseMap<K, V>
impl<K, V> Index<K> for UnmanagedDenseMap<K, V>
Source§impl<K, V> IndexMut<K> for UnmanagedDenseMap<K, V>
impl<K, V> IndexMut<K> for UnmanagedDenseMap<K, V>
Source§impl<K, V> SecondaryMap<K, V> for UnmanagedDenseMap<K, V>
impl<K, V> SecondaryMap<K, V> for UnmanagedDenseMap<K, V>
Source§fn new() -> Self
fn new() -> Self
Creates a new secondary map.
This does not allocate any memory until a value is modified.
Source§fn set(&mut self, key: K, val: V)
fn set(&mut self, key: K, val: V)
Sets the value at a key.
When the value is not present, the secondary map is resized to accommodate it.
To avoid frequent resizing, use SecondaryMap::ensure_capacity to keep the
capacity of the secondary map in line with the size of the key space.
Source§fn take(&mut self, key: K) -> V
fn take(&mut self, key: K) -> V
Takes the value at a key, leaving default() behind.
This operation does not free memory. Use
UnmanagedDenseMap::shrink_to to trim container if needed.
Source§type Iter<'a> = UnmanagedIter<'a, K, V>
where
Self: 'a,
K: 'a,
V: 'a
type Iter<'a> = UnmanagedIter<'a, K, V> where Self: 'a, K: 'a, V: 'a
Source§fn with_capacity(capacity: usize) -> Self
fn with_capacity(capacity: usize) -> Self
Source§fn default_value(&self) -> V
fn default_value(&self) -> V
Source§fn ensure_capacity(&mut self, capacity: usize)
fn ensure_capacity(&mut self, capacity: usize)
capacity.Source§fn capacity(&self) -> usize
fn capacity(&self) -> usize
Auto Trait Implementations§
impl<K, V> Freeze for UnmanagedDenseMap<K, V>where
V: Freeze,
impl<K, V> RefUnwindSafe for UnmanagedDenseMap<K, V>where
V: RefUnwindSafe,
K: RefUnwindSafe,
impl<K, V> Send for UnmanagedDenseMap<K, V>
impl<K, V> Sync for UnmanagedDenseMap<K, V>
impl<K, V> Unpin for UnmanagedDenseMap<K, V>
impl<K, V> UnwindSafe for UnmanagedDenseMap<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§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.