Struct AHashMap
pub struct AHashMap<K, V, S = RandomState>(/* private field */);
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 creates 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 creates 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>
where
K: Hash + Eq,
S: BuildHasher,
fn get<Q>(&self, k: &Q) -> Option<&V> where K: Borrow<Q>, Q: Hash + Eq + ?Sized,Returns 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, k: &Q) -> Option<(&K, &V)> where K: Borrow<Q>, Q: Hash + Eq + ?Sized,Returns 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>(&mut self, k: &Q) -> Option<&mut V> where K: Borrow<Q>, Q: Hash + Eq + ?Sized,Returns 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(&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) -> 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) -> 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>(&mut self, k: &Q) -> Option<V> where K: Borrow<Q>, Q: Hash + Eq + ?Sized,Removes 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<K, V, S> AHashMap<K, V, S>
where
S: BuildHasher,
fn with_hasher(hash_builder: S) -> Selffn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Trait Implementations
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for AHashMap<K, V, S>
where
K: Eq + Hash + Copy + 'a,
V: Copy + 'a,
S: BuildHasher,
fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: T)
impl<K, Q, V, S> Index<&Q> for AHashMap<K, V, S>
where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash + ?Sized,
S: BuildHasher,
type Output = V;fn index(&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<HashMap<K, V, RandomState>> for AHashMap<K, V>
fn from(item: HashMap<K, V, RandomState>) -> Self
impl<K, V> FromIterator<(K, V)> for AHashMap<K, V, RandomState>
where
K: Eq + Hash,
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> SelfThis creates a hashmap from the provided iterator using [RandomState::new]. See the documentation in [RandomSource] for notes about key strength.
impl<K, V> Into<HashMap<K, V, RandomState>> for AHashMap<K, V>
fn into(self) -> HashMap<K, V, RandomState>
impl<K, V, S> Debug for AHashMap<K, V, S>
where
K: Debug,
V: Debug,
S: BuildHasher,
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<K, V, S> Deref for AHashMap<K, V, S>
type Target = HashMap<K, V, S>;fn deref(&self) -> &Self::Target
impl<K, V, S> DerefMut for AHashMap<K, V, S>
fn deref_mut(&mut self) -> &mut Self::Target
impl<K, V, S> Eq for AHashMap<K, V, S>
where
K: Eq + Hash,
V: Eq,
S: BuildHasher,
impl<K, V, S> Extend<(K, V)> for AHashMap<K, V, S>
where
K: Eq + Hash,
S: BuildHasher,
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
impl<K, V, S> IntoIterator for AHashMap<K, V, S>
type Item = (K, V);type IntoIter = IntoIter<K, V>;fn into_iter(self) -> Self::IntoIter
impl<K, V, S> PartialEq for AHashMap<K, V, S>
where
K: Eq + Hash,
V: PartialEq,
S: BuildHasher,
fn eq(&self, other: &AHashMap<K, V, S>) -> bool
impl<K, V, S> UnwindSafe for AHashMap<K, V, S>
where
K: UnwindSafe,
V: UnwindSafe,
impl<K, V, const N: usize> From<[(K, V); N]> for AHashMap<K, V>
where
K: Eq + Hash,
fn from(arr: [(K, V); N]) -> SelfExamples
use AHashMap; let map1 = from; let map2: = .into; assert_eq!;
impl<K: Clone, V: Clone, S: Clone> Clone for AHashMap<K, V, S>
fn clone(&self) -> AHashMap<K, V, S>
Auto Trait Implementations
impl<K, V, S> Freeze for AHashMap<K, V, S>
where
HashMap<K, V, S>: Freeze,
impl<K, V, S> RefUnwindSafe for AHashMap<K, V, S>
where
HashMap<K, V, S>: RefUnwindSafe,
impl<K, V, S> Send for AHashMap<K, V, S>
where
HashMap<K, V, S>: Send,
impl<K, V, S> Sync for AHashMap<K, V, S>
where
HashMap<K, V, S>: Sync,
impl<K, V, S> Unpin for AHashMap<K, V, S>
where
HashMap<K, V, S>: Unpin,
impl<K, V, S> UnsafeUnpin for AHashMap<K, V, S>
where
HashMap<K, V, S>: UnsafeUnpin,
Blanket Implementations
impl<P, T> Receiver for AHashMap<K, V, S>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for AHashMap<K, V, S>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for AHashMap<K, V, S>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for AHashMap<K, V, S>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for AHashMap<K, V, S>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for AHashMap<K, V, S>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for AHashMap<K, V, S>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for AHashMap<K, V, S>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for AHashMap<K, V, S>
where
T: ?Sized,
impl<T> ToOwned for AHashMap<K, V, S>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for AHashMap<K, V, S>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for AHashMap<K, V, S>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for AHashMap<K, V, S>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>