Struct AHashMap
struct AHashMap<K, V, S = crate::RandomState>(_)
A HashMap using RandomState to hash the items.
(Requires the std feature to be enabled.)
Implementations
impl<K, V> AHashMap<K, V, RandomState>
fn new() -> SelfThis crates a hashmap using [RandomState::new] which obtains its keys from [RandomSource]. See the documentation in [RandomSource] for notes about key strength.
fn with_capacity(capacity: usize) -> SelfThis crates a hashmap with the specified capacity using [RandomState::new]. See the documentation in [RandomSource] for notes about key strength.
impl<K, V, S> AHashMap<K, V, S>
fn with_hasher(hash_builder: S) -> Selffn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
impl<K, V, S> AHashMap<K, V, S>
fn get<Q>(self: &Self, k: &Q) -> Option<&V> where K: Borrow<Q>, Q: Hash + Eq + ?SizedReturns a reference to the value corresponding to the key.
The key may be any borrowed form of the map's key type, but
HashandEqon the borrowed form must match those for the key type.Examples
use HashMap; let mut map = new; map.insert; assert_eq!; assert_eq!;fn get_key_value<Q>(self: &Self, k: &Q) -> Option<(&K, &V)> where K: Borrow<Q>, Q: Hash + Eq + ?SizedReturns the key-value pair corresponding to the supplied key.
The supplied key may be any borrowed form of the map's key type, but
HashandEqon the borrowed form must match those for the key type.Examples
use HashMap; let mut map = new; map.insert; assert_eq!; assert_eq!;fn get_mut<Q>(self: &mut Self, k: &Q) -> Option<&mut V> where K: Borrow<Q>, Q: Hash + Eq + ?SizedReturns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map's key type, but
HashandEqon the borrowed form must match those for the key type.Examples
use HashMap; let mut map = new; map.insert; if let Some = map.get_mut assert_eq!;fn insert(self: &mut Self, k: K, v: V) -> Option<V>Inserts a key-value pair into the map.
If the map did not have this key present,
Noneis returned.If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be
==without being identical. See the [module-level documentation] for more.Examples
use HashMap; let mut map = new; assert_eq!; assert_eq!; map.insert; assert_eq!; assert_eq!;fn into_keys(self: Self) -> IntoKeys<K, V>Creates a consuming iterator visiting all the keys in arbitrary order. The map cannot be used after calling this. The iterator element type is
K.Examples
use HashMap; let map = from; let mut vec: = map.into_keys.collect; // The `IntoKeys` iterator produces keys in arbitrary order, so the // keys must be sorted to test them against a sorted array. vec.sort_unstable; assert_eq!;Performance
In the current implementation, iterating over keys takes O(capacity) time instead of O(len) because it internally visits empty buckets too.
fn into_values(self: Self) -> IntoValues<K, V>Creates a consuming iterator visiting all the values in arbitrary order. The map cannot be used after calling this. The iterator element type is
V.Examples
use HashMap; let map = from; let mut vec: = map.into_values.collect; // The `IntoValues` iterator produces values in arbitrary order, so // the values must be sorted to test them against a sorted array. vec.sort_unstable; assert_eq!;Performance
In the current implementation, iterating over values takes O(capacity) time instead of O(len) because it internally visits empty buckets too.
fn remove<Q>(self: &mut Self, k: &Q) -> Option<V> where K: Borrow<Q>, Q: Hash + Eq + ?SizedRemoves a key from the map, returning the value at the key if the key was previously in the map.
The key may be any borrowed form of the map's key type, but
HashandEqon the borrowed form must match those for the key type.Examples
use HashMap; let mut map = new; map.insert; assert_eq!; assert_eq!;
impl<'a, K, V, S> Extend for AHashMap<K, V, S>
fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(self: &mut Self, iter: T)
impl<K, Q, V, S> Index for AHashMap<K, V, S>
fn index(self: &Self, key: &Q) -> &VReturns a reference to the value corresponding to the supplied key.
Panics
Panics if the key is not present in the
HashMap.
impl<K, V> Default for AHashMap<K, V, RandomState>
fn default() -> AHashMap<K, V, RandomState>
impl<K, V> From for AHashMap<K, V>
fn from(item: HashMap<K, V, RandomState>) -> Self
impl<K, V> FromIterator for AHashMap<K, V, RandomState>
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> SelfThis crates a hashmap from the provided iterator using [RandomState::new]. See the documentation in [RandomSource] for notes about key strength.
impl<K, V> Into for AHashMap<K, V>
fn into(self: Self) -> HashMap<K, V, RandomState>
impl<K, V, N: usize> From for AHashMap<K, V>
fn from(arr: [(K, V); N]) -> SelfExamples
use AHashMap; let map1 = from; let map2: = .into; assert_eq!;
impl<K, V, S> Debug for AHashMap<K, V, S>
fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result
impl<K, V, S> Deref for AHashMap<K, V, S>
fn deref(self: &Self) -> &<Self as >::Target
impl<K, V, S> DerefMut for AHashMap<K, V, S>
fn deref_mut(self: &mut Self) -> &mut <Self as >::Target
impl<K, V, S> Eq for AHashMap<K, V, S>
impl<K, V, S> Extend for AHashMap<K, V, S>
fn extend<T: IntoIterator<Item = (K, V)>>(self: &mut Self, iter: T)
impl<K, V, S> Freeze for AHashMap<K, V, S>
impl<K, V, S> IntoIterator for AHashMap<K, V, S>
fn into_iter(self: Self) -> <Self as >::IntoIter
impl<K, V, S> PartialEq for AHashMap<K, V, S>
fn eq(self: &Self, other: &AHashMap<K, V, S>) -> bool
impl<K, V, S> RefUnwindSafe for AHashMap<K, V, S>
impl<K, V, S> Send for AHashMap<K, V, S>
impl<K, V, S> Sync for AHashMap<K, V, S>
impl<K, V, S> Unpin for AHashMap<K, V, S>
impl<K, V, S> UnsafeUnpin for AHashMap<K, V, S>
impl<K, V, S> UnwindSafe for AHashMap<K, V, S>
impl<K: $crate::clone::Clone, V: $crate::clone::Clone, S: $crate::clone::Clone> Clone for AHashMap<K, V, S>
fn clone(self: &Self) -> AHashMap<K, V, S>
impl<P, T> Receiver for AHashMap<K, V, S>
impl<T> Any for AHashMap<K, V, S>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for AHashMap<K, V, S>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for AHashMap<K, V, S>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for AHashMap<K, V, S>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for AHashMap<K, V, S>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for AHashMap<K, V, S>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for AHashMap<K, V, S>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for AHashMap<K, V, S>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for AHashMap<K, V, S>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>