Struct hashlink::linked_hash_map::LinkedHashMap
source · pub struct LinkedHashMap<K, V, S = DefaultHashBuilder> { /* private fields */ }Expand description
A version of HashMap that has a user controllable order for its entries.
It achieves this by keeping its entries in an internal linked list and using a HashMap to
point at nodes in this linked list.
The order of entries defaults to “insertion order”, but the user can also modify the order of existing entries by manually moving them to the front or back.
There are two kinds of methods that modify the order of the internal list:
- Methods that have names like
to_frontandto_backwill unsurprisingly move an existing entry to the front or back - Methods that have the word
insertwill insert a new entry ot the back of the list, and if that method might replace an entry, that method will also move that existing entry to the back.
Implementations§
source§impl<K, V> LinkedHashMap<K, V>
impl<K, V> LinkedHashMap<K, V>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
source§impl<K, V, S> LinkedHashMap<K, V, S>
impl<K, V, S> LinkedHashMap<K, V, S>
pub fn with_hasher(hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn reserve(&mut self, additional: usize)
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn shrink_to_fit(&mut self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn drain(&mut self) -> Drain<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn front(&self) -> Option<(&K, &V)>
pub fn back(&self) -> Option<(&K, &V)>
pub fn retain<F>(&mut self, f: F)
pub fn hasher(&self) -> &S
pub fn capacity(&self) -> usize
source§impl<K, V, S> LinkedHashMap<K, V, S>
impl<K, V, S> LinkedHashMap<K, V, S>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
pub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts the given key / value pair at the back of the internal linked list.
Returns the previously set value, if one existed prior to this call. After this call,
calling LinkedHashMap::back will return a reference to this key / value pair.
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
pub fn pop_front(&mut self) -> Option<(K, V)>
pub fn pop_back(&mut self) -> Option<(K, V)>
source§impl<K, V, S> LinkedHashMap<K, V, S>where
S: BuildHasher,
impl<K, V, S> LinkedHashMap<K, V, S>where
S: BuildHasher,
pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
Trait Implementations§
source§impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher + Clone> Clone for LinkedHashMap<K, V, S>
impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher + Clone> Clone for LinkedHashMap<K, V, S>
source§impl<K, V, S> Debug for LinkedHashMap<K, V, S>
impl<K, V, S> Debug for LinkedHashMap<K, V, S>
source§impl<K, V, S> Default for LinkedHashMap<K, V, S>where
S: Default,
impl<K, V, S> Default for LinkedHashMap<K, V, S>where
S: Default,
source§impl<K, V, S> Drop for LinkedHashMap<K, V, S>
impl<K, V, S> Drop for LinkedHashMap<K, V, S>
source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for LinkedHashMap<K, V, S>
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for LinkedHashMap<K, V, S>
source§fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬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: Hash + Eq, V, S: BuildHasher> Extend<(K, V)> for LinkedHashMap<K, V, S>
impl<K: Hash + Eq, V, S: BuildHasher> Extend<(K, V)> for LinkedHashMap<K, V, S>
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: A)
fn extend_one(&mut self, item: A)
🔬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: Hash + Eq, V, S: BuildHasher + Default> FromIterator<(K, V)> for LinkedHashMap<K, V, S>
impl<K: Hash + Eq, V, S: BuildHasher + Default> FromIterator<(K, V)> for LinkedHashMap<K, V, S>
source§impl<K: Hash + Eq, V: Hash, S: BuildHasher> Hash for LinkedHashMap<K, V, S>
impl<K: Hash + Eq, V: Hash, S: BuildHasher> Hash for LinkedHashMap<K, V, S>
source§impl<'a, K, V, S, Q> Index<&'a Q> for LinkedHashMap<K, V, S>
impl<'a, K, V, S, Q> Index<&'a Q> for LinkedHashMap<K, V, S>
source§impl<'a, K, V, S, Q> IndexMut<&'a Q> for LinkedHashMap<K, V, S>
impl<'a, K, V, S, Q> IndexMut<&'a Q> for LinkedHashMap<K, V, S>
source§impl<'a, K, V, S> IntoIterator for &'a LinkedHashMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a LinkedHashMap<K, V, S>
source§impl<'a, K, V, S> IntoIterator for &'a mut LinkedHashMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a mut LinkedHashMap<K, V, S>
source§impl<K, V, S> IntoIterator for LinkedHashMap<K, V, S>
impl<K, V, S> IntoIterator for LinkedHashMap<K, V, S>
source§impl<K: Hash + Eq + Ord, V: Ord, S: BuildHasher> Ord for LinkedHashMap<K, V, S>
impl<K: Hash + Eq + Ord, V: Ord, S: BuildHasher> Ord for LinkedHashMap<K, V, S>
source§impl<K: Hash + Eq, V: PartialEq, S: BuildHasher> PartialEq for LinkedHashMap<K, V, S>
impl<K: Hash + Eq, V: PartialEq, S: BuildHasher> PartialEq for LinkedHashMap<K, V, S>
source§impl<K: Hash + Eq + PartialOrd, V: PartialOrd, S: BuildHasher> PartialOrd for LinkedHashMap<K, V, S>
impl<K: Hash + Eq + PartialOrd, V: PartialOrd, S: BuildHasher> PartialOrd for LinkedHashMap<K, V, S>
source§fn le(&self, other: &Self) -> bool
fn le(&self, other: &Self) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl<K: Hash + Eq, V: Eq, S: BuildHasher> Eq for LinkedHashMap<K, V, S>
impl<K: Send, V: Send, S: Send> Send for LinkedHashMap<K, V, S>
impl<K: Sync, V: Sync, S: Sync> Sync for LinkedHashMap<K, V, S>
Auto Trait Implementations§
impl<K, V, S> RefUnwindSafe for LinkedHashMap<K, V, S>
impl<K, V, S> Unpin for LinkedHashMap<K, V, S>where
S: Unpin,
impl<K, V, S> UnwindSafe for LinkedHashMap<K, V, S>
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