pub struct OrderedHashMap<Key, Value, BH = RandomState>(/* private fields */);
Implementations§
source§impl<Key, Value, BH> OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> OrderedHashMap<Key, Value, BH>
sourcepub fn iter(&self) -> Iter<'_, Key, Value>
pub fn iter(&self) -> Iter<'_, Key, Value>
Returns an iterator over the key-value pairs of the map, in their order.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, Key, Value>
pub fn iter_mut(&mut self) -> IterMut<'_, Key, Value>
Returns a mutable iterator over the key-value pairs of the map, in their order.
sourcepub fn keys(&self) -> Keys<'_, Key, Value>
pub fn keys(&self) -> Keys<'_, Key, Value>
Returns an iterator over the keys of the map, in their order.
sourcepub fn into_keys(self) -> IntoKeys<Key, Value>
pub fn into_keys(self) -> IntoKeys<Key, Value>
Returns a consuming iterator over the keys of the map, in their order.
sourcepub fn values(&self) -> Values<'_, Key, Value>
pub fn values(&self) -> Values<'_, Key, Value>
Returns an iterator over the values of the map, in their order.
sourcepub fn shift_remove_index(&mut self, index: usize) -> Option<(Key, Value)>
pub fn shift_remove_index(&mut self, index: usize) -> Option<(Key, Value)>
Removes the entry at the given index.
Returns the key-value pair at the given index (if present).
source§impl<Key: Eq + Hash, Value, BH: BuildHasher> OrderedHashMap<Key, Value, BH>
impl<Key: Eq + Hash, Value, BH: BuildHasher> OrderedHashMap<Key, Value, BH>
sourcepub fn get<Q: ?Sized + Hash + Equivalent<Key>>(&self, key: &Q) -> Option<&Value>
pub fn get<Q: ?Sized + Hash + Equivalent<Key>>(&self, key: &Q) -> Option<&Value>
Returns a reference to the value stored for key, if it is present, else None.
Computes in O(1) time (average).
sourcepub fn get_mut<Q: ?Sized + Hash + Equivalent<Key>>(
&mut self,
key: &Q,
) -> Option<&mut Value>
pub fn get_mut<Q: ?Sized + Hash + Equivalent<Key>>( &mut self, key: &Q, ) -> Option<&mut Value>
Returns a mutable reference to the value stored for key, if it is present, else None.
Computes in O(1) time (average).
sourcepub fn entry(&mut self, key: Key) -> Entry<'_, Key, Value>
pub fn entry(&mut self, key: Key) -> Entry<'_, Key, Value>
Gets the given key’s corresponding entry in the map for insertion and/or in-place manipulation.
Computes in O(1) time (amortized average).
sourcepub fn insert(&mut self, key: Key, value: Value) -> Option<Value>
pub fn insert(&mut self, key: Key, value: Value) -> Option<Value>
Insert a key-value pair in the map.
If an equivalent key already exists in the map: the key remains and retains in its place in the order, its corresponding value is updated with value and the older value is returned inside Some(_).
If no equivalent key existed in the map: the new key-value pair is inserted, last in order, and None is returned.
Computes in O(1) time (amortized average).
See also entry if you you want to insert or modify or if you need to get the index of the corresponding key-value pair.
sourcepub fn extend<I: IntoIterator<Item = (Key, Value)>>(&mut self, iter: I)
pub fn extend<I: IntoIterator<Item = (Key, Value)>>(&mut self, iter: I)
Extends the map with the content of the given iterator.
sourcepub fn contains_key<Q: ?Sized + Hash + Equivalent<Key>>(&self, key: &Q) -> bool
pub fn contains_key<Q: ?Sized + Hash + Equivalent<Key>>(&self, key: &Q) -> bool
Returns true if an equivalent to key exists in the map.
sourcepub fn shift_remove<Q: ?Sized + Hash + Equivalent<Key>>(
&mut self,
key: &Q,
) -> Option<Value>
pub fn shift_remove<Q: ?Sized + Hash + Equivalent<Key>>( &mut self, key: &Q, ) -> Option<Value>
Removes the entry for the given key, preserving the order of entries.
Returns the value associated with the key (if present).
sourcepub fn swap_remove<Q: ?Sized + Hash + Equivalent<Key>>(
&mut self,
key: &Q,
) -> Option<Value>
pub fn swap_remove<Q: ?Sized + Hash + Equivalent<Key>>( &mut self, key: &Q, ) -> Option<Value>
Removes the entry for the given key by swapping it with the last element. Thus the order of elements is not preserved, but the resulting order is still deterministic.
Returns the value associated with the key (if present).
sourcepub fn retain(&mut self, keep: impl FnMut(&Key, &mut Value) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&Key, &mut Value) -> bool)
Scan through each key-value pair in the map and keep those where the
closure keep
returns true
.
The elements are visited in order, and remaining elements keep their order.
Computes in O(n) time (average).
sourcepub fn eq_unordered(&self, other: &Self) -> boolwhere
Value: Eq,
pub fn eq_unordered(&self, other: &Self) -> boolwhere
Value: Eq,
Returns true if the maps are equal, ignoring the order of the entries.
Trait Implementations§
source§impl<Key: Clone, Value: Clone, BH: Clone> Clone for OrderedHashMap<Key, Value, BH>
impl<Key: Clone, Value: Clone, BH: Clone> Clone for OrderedHashMap<Key, Value, BH>
source§fn clone(&self) -> OrderedHashMap<Key, Value, BH>
fn clone(&self) -> OrderedHashMap<Key, Value, BH>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Key, Value, BH: Default> Default for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH: Default> Default for OrderedHashMap<Key, Value, BH>
source§impl<Key: Hash + Eq, Value, BH: BuildHasher + Default, const N: usize> From<[(Key, Value); N]> for OrderedHashMap<Key, Value, BH>
impl<Key: Hash + Eq, Value, BH: BuildHasher + Default, const N: usize> From<[(Key, Value); N]> for OrderedHashMap<Key, Value, BH>
source§fn from(init_map: [(Key, Value); N]) -> Self
fn from(init_map: [(Key, Value); N]) -> Self
source§impl<Key: Hash + Eq, Value, BH: BuildHasher + Default> FromIterator<(Key, Value)> for OrderedHashMap<Key, Value, BH>
impl<Key: Hash + Eq, Value, BH: BuildHasher + Default> FromIterator<(Key, Value)> for OrderedHashMap<Key, Value, BH>
source§fn from_iter<T: IntoIterator<Item = (Key, Value)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (Key, Value)>>(iter: T) -> Self
source§impl<Key, Value, Q, BH> Index<&Q> for OrderedHashMap<Key, Value, BH>
impl<Key, Value, Q, BH> Index<&Q> for OrderedHashMap<Key, Value, BH>
source§impl<Key, Value, Q, BH> IndexMut<&Q> for OrderedHashMap<Key, Value, BH>
impl<Key, Value, Q, BH> IndexMut<&Q> for OrderedHashMap<Key, Value, BH>
source§impl<Key, Value, BH> IntoIterator for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> IntoIterator for OrderedHashMap<Key, Value, BH>
impl<Key: Hash + Eq, Value: Eq, BH: BuildHasher> Eq for OrderedHashMap<Key, Value, BH>
Auto Trait Implementations§
impl<Key, Value, BH> Freeze for OrderedHashMap<Key, Value, BH>where
BH: Freeze,
impl<Key, Value, BH> RefUnwindSafe for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> Send for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> Sync for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> Unpin for OrderedHashMap<Key, Value, BH>
impl<Key, Value, BH> UnwindSafe for OrderedHashMap<Key, Value, BH>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more