pub struct OrderedMap<V> { /* private fields */ }Expand description
A map from node names to V that iterates in insertion order.
Inserting an existing key replaces its value in place, as a Python dict does. Lookups are linear: the maps hold one entry per network node, a few dozen at most, where a scan beats hashing.
Implementations§
Source§impl<V> OrderedMap<V>
impl<V> OrderedMap<V>
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut V>
pub fn get_mut(&mut self, key: &str) -> Option<&mut V>
Returns a mutable reference to the value stored under key.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true when key is present.
Sourcepub fn insert(&mut self, key: impl Into<String>, value: V) -> Option<V>
pub fn insert(&mut self, key: impl Into<String>, value: V) -> Option<V>
Inserts value under key, returning the value it replaced. A new key
goes last; an existing key keeps its position.
Sourcepub fn remove(&mut self, key: &str) -> Option<V>
pub fn remove(&mut self, key: &str) -> Option<V>
Removes key, keeping the order of the remaining entries.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (&str, &V)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (&str, &V)>
Iterates over the entries in insertion order.
Sourcepub fn keys(&self) -> impl ExactSizeIterator<Item = &str>
pub fn keys(&self) -> impl ExactSizeIterator<Item = &str>
Iterates over the keys in insertion order.
Trait Implementations§
Source§impl<V: Clone> Clone for OrderedMap<V>
impl<V: Clone> Clone for OrderedMap<V>
Source§impl<V: Debug> Debug for OrderedMap<V>
impl<V: Debug> Debug for OrderedMap<V>
Source§impl<V> Default for OrderedMap<V>
impl<V> Default for OrderedMap<V>
impl<V: Eq> Eq for OrderedMap<V>
Source§impl<K: Into<String>, V> Extend<(K, V)> for OrderedMap<V>
impl<K: Into<String>, V> Extend<(K, V)> for OrderedMap<V>
Source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K: Into<String>, V> FromIterator<(K, V)> for OrderedMap<V>
impl<K: Into<String>, V> FromIterator<(K, V)> for OrderedMap<V>
Source§impl<V> IntoIterator for OrderedMap<V>
impl<V> IntoIterator for OrderedMap<V>
Source§impl<'a, V> IntoIterator for &'a OrderedMap<V>
impl<'a, V> IntoIterator for &'a OrderedMap<V>
Source§impl<V: PartialEq> PartialEq for OrderedMap<V>
impl<V: PartialEq> PartialEq for OrderedMap<V>
impl<V: PartialEq> StructuralPartialEq for OrderedMap<V>
Auto Trait Implementations§
impl<V> Freeze for OrderedMap<V>
impl<V> RefUnwindSafe for OrderedMap<V>
impl<V> Send for OrderedMap<V>
impl<V> Sync for OrderedMap<V>
impl<V> Unpin for OrderedMap<V>
impl<V> UnsafeUnpin for OrderedMap<V>
impl<V> UnwindSafe for OrderedMap<V>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.