Struct ds_ext::queue::LinkedHashMap
source · 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) -> boolwhere
Arc<K>: Borrow<Q>,
Q: Eq + Hash + ?Sized,
pub fn contains_key<Q>(&self, key: &Q) -> boolwhere Arc<K>: Borrow<Q>, Q: Eq + Hash + ?Sized,
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<Q>(&self, key: &Q) -> Option<&V>where
Arc<K>: Borrow<Q>,
Q: Eq + Hash + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&V>where Arc<K>: Borrow<Q>, Q: Eq + Hash + ?Sized,
Borrow the value at the given key
, if present.
sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>where
Arc<K>: Borrow<Q>,
Q: Eq + Hash + ?Sized,
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>where Arc<K>: Borrow<Q>, Q: Eq + Hash + ?Sized,
Borrow the entry at the given key
, if present.
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where
Arc<K>: Borrow<Q>,
Q: Eq + Hash + ?Sized,
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where Arc<K>: Borrow<Q>, Q: Eq + Hash + ?Sized,
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>where
Arc<K>: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>where Arc<K>: Borrow<Q>, Q: Hash + Eq + ?Sized,
Remove an entry from this LinkedHashMap
and return its value, if present.
sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>where
K: Debug,
Arc<K>: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>where K: Debug, Arc<K>: Borrow<Q>, Q: Hash + Eq + ?Sized,
Remove and return an entry from this LinkedHashMap
, if present.
sourcepub fn swap<Q>(&mut self, l: &Q, r: &Q) -> boolwhere
Arc<K>: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn swap<Q>(&mut self, l: &Q, r: &Q) -> boolwhere Arc<K>: Borrow<Q>, Q: Hash + Eq + ?Sized,
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
.