Struct portgraph::UnmanagedDenseMap
source · 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>where
K: Into<usize> + Copy,
V: Clone,
impl<K, V> UnmanagedDenseMap<K, V>where K: Into<usize> + Copy, V: Clone,
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 fn with_default(default: V) -> Self
pub 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
PortGraph::set_num_ports and PortGraph::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>where
K: Into<usize> + Copy,
V: Clone + Default,
impl<K, V> Default for UnmanagedDenseMap<K, V>where K: Into<usize> + Copy, V: Clone + Default,
source§impl<K: PartialEq, V: PartialEq> PartialEq<UnmanagedDenseMap<K, V>> for UnmanagedDenseMap<K, V>
impl<K: PartialEq, V: PartialEq> PartialEq<UnmanagedDenseMap<K, V>> for UnmanagedDenseMap<K, V>
source§impl<K, V> SecondaryMap<K, V> for UnmanagedDenseMap<K, V>where
K: Into<usize> + TryFrom<usize> + Copy,
V: Clone + Default,
impl<K, V> SecondaryMap<K, V> for UnmanagedDenseMap<K, V>where K: Into<usize> + TryFrom<usize> + Copy, V: Clone + Default,
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.
§type Iter<'a>
where
Self: 'a,
K: 'a,
V: 'a = UnmanagedIter<'a, K, V>
type Iter<'a> where Self: 'a, K: 'a, V: 'a = UnmanagedIter<'a, K, V>
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> RefUnwindSafe for UnmanagedDenseMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,
impl<K, V> Send for UnmanagedDenseMap<K, V>where K: Send, V: Send,
impl<K, V> Sync for UnmanagedDenseMap<K, V>where K: Sync, V: Sync,
impl<K, V> Unpin for UnmanagedDenseMap<K, V>where K: Unpin, V: Unpin,
impl<K, V> UnwindSafe for UnmanagedDenseMap<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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§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 more§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 more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target of a value. Read more§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.§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.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.