pub struct LinkedHashMap<K, V> { /* private fields */ }
Expand description
A hash map in insertion order which can be reordered using Self::bump
and Self::swap
.
Implementations§
Source§impl<K: Eq + Hash, V> LinkedHashMap<K, V>
impl<K: Eq + Hash, V> LinkedHashMap<K, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new LinkedHashMap
.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct a new LinkedHashMap
with the given capacity
.
Sourcepub fn bump(&mut self, key: &K) -> bool
pub fn bump(&mut self, key: &K) -> bool
If key
is present, increase its priority by one and return true
.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all entries from this LinkedHashMap
.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Return true
if there is an entry for the given key
in this LinkedHashMap
.
Sourcepub fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
pub fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Consume the iter
and insert all its elements into this LinkedHashMap
.
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Borrow the entry at the given key
, if present.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Borrow the value at the given key
mutably, if present.
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Insert a new value
at key
and return the previous value, if any.
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Construct an iterator over the entries in this LinkedHashMap
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true
if this LinkedHashMap
is empty.
Sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
Construct an iterator over keys of this LinkedHashMap
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the size of this LinkedHashMap
.
Sourcepub fn pop_first(&mut self) -> Option<V>
pub fn pop_first(&mut self) -> Option<V>
Remove and return the first value in this LinkedHashMap
.
Sourcepub fn pop_first_entry(&mut self) -> Option<(K, V)>where
K: Debug,
pub fn pop_first_entry(&mut self) -> Option<(K, V)>where
K: Debug,
Remove and return the first entry in this LinkedHashMap
.
Sourcepub fn pop_last(&mut self) -> Option<V>
pub fn pop_last(&mut self) -> Option<V>
Remove and return the last value in this LinkedHashMap
.
Sourcepub fn pop_last_entry(&mut self) -> Option<(K, V)>where
K: Debug,
pub fn pop_last_entry(&mut self) -> Option<(K, V)>where
K: Debug,
Remove and return the last entry in this LinkedHashMap
.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
Remove an entry from this LinkedHashMap
and return its value, if present.
Sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
Remove and return an entry from this LinkedHashMap
, if present.
Sourcepub fn swap<Q>(&mut self, l: &Q, r: &Q) -> bool
pub fn swap<Q>(&mut self, l: &Q, r: &Q) -> bool
Swap the position of two keys in this LinkedHashMap
.
Returns true
if both keys are present.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Construct an iterator over the values in this LinkedHashMap
.