Struct ritelinked::LinkedHashMap [−][src]
pub struct LinkedHashMap<K, V, S = DefaultHashBuilder> { /* fields omitted */ }
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_front
andto_back
will unsurprisingly move an existing entry to the front or back - Methods that have the word
insert
will 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
pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_refresh<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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.
If the given key is not in this map, inserts the key / value pair at the back of the
internal linked list and returns None
, otherwise, replaces the existing value with the
given value without moving the entry in the internal linked list and returns the previous
value.
pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
If an entry with this key exists, move it to the front of the list and return a reference to the value.
Trait Implementations
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for LinkedHashMap<K, V, S> where
K: 'a + Hash + Eq + Copy,
V: 'a + Copy,
S: BuildHasher,
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for LinkedHashMap<K, V, S> where
K: 'a + Hash + Eq + Copy,
V: 'a + Copy,
S: BuildHasher,
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
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>
Creates a value from an iterator. Read more
type Item = (&'a K, &'a V)
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type Item = (&'a K, &'a mut V)
type Item = (&'a K, &'a mut V)
The type of the elements being iterated over.
type Item = (K, V)
type Item = (K, V)
The type of the elements being iterated over.
impl<K: Hash + Eq, V: PartialEq, S: BuildHasher> PartialEq<LinkedHashMap<K, V, S>> for LinkedHashMap<K, V, S>
impl<K: Hash + Eq, V: PartialEq, S: BuildHasher> PartialEq<LinkedHashMap<K, V, S>> for LinkedHashMap<K, V, S>
impl<K: Hash + Eq + PartialOrd, V: PartialOrd, S: BuildHasher> PartialOrd<LinkedHashMap<K, V, S>> for LinkedHashMap<K, V, S>
impl<K: Hash + Eq + PartialOrd, V: PartialOrd, S: BuildHasher> PartialOrd<LinkedHashMap<K, V, S>> for LinkedHashMap<K, V, S>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
Auto Trait Implementations
impl<K, V, S> RefUnwindSafe for LinkedHashMap<K, V, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, S> Unpin for LinkedHashMap<K, V, S> where
S: Unpin,
impl<K, V, S> UnwindSafe for LinkedHashMap<K, V, S> where
K: RefUnwindSafe,
S: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more