Struct weak_table::WeakKeyHashMap
[−]
[src]
pub struct WeakKeyHashMap<K, V, S = RandomState> { /* fields omitted */ }
A hash map with weak keys, hashed on key value.
When a weak pointer expires, its mapping is lazily removed.
Methods
impl<K: WeakKey, V> WeakKeyHashMap<K, V, RandomState>
[src]
impl<K: WeakKey, V> WeakKeyHashMap<K, V, RandomState>
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates an empty WeakKeyHashMap
.
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
Creates an empty WeakKeyHashMap
with the given capacity.
impl<K: WeakKey, V, S: BuildHasher> WeakKeyHashMap<K, V, S>
[src]
impl<K: WeakKey, V, S: BuildHasher> WeakKeyHashMap<K, V, S>
pub fn with_hasher(hash_builder: S) -> Self
[src]
pub fn with_hasher(hash_builder: S) -> Self
Creates an empty WeakKeyHashMap
with the given capacity and hasher.
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
[src]
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates an empty WeakKeyHashMap
with the given capacity and hasher.
pub fn hasher(&self) -> &S
[src]
pub fn hasher(&self) -> &S
Returns a reference to the map's BuildHasher
.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
pub fn remove_expired(&mut self)
[src]
pub fn remove_expired(&mut self)
Removes all mappings whose keys have expired.
pub fn reserve(&mut self, additional_capacity: usize)
[src]
pub fn reserve(&mut self, additional_capacity: usize)
Reserves room for additional elements.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
Shrinks the capacity to the minimum allowed to hold the current number of elements.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns an over-approximation of the number of elements.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Is the map empty?
Note that this may return false even if all keys in the map have expired, if they haven't been collected yet.
pub fn load_factor(&self) -> f32
[src]
pub fn load_factor(&self) -> f32
The proportion of buckets that are used.
This is an over-approximation because of expired keys.
pub fn entry(&mut self, key: K::Strong) -> Entry<K, V>
[src]
pub fn entry(&mut self, key: K::Strong) -> Entry<K, V>
Gets the requested entry.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Removes all associations from the map.
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns a reference to the value corresponding to the key.
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns true if the map contains the specified key.
pub fn get_key<Q: ?Sized>(&self, key: &Q) -> Option<K::Strong> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn get_key<Q: ?Sized>(&self, key: &Q) -> Option<K::Strong> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns a strong reference to the key, if found.
pub fn get_both<Q: ?Sized>(&self, key: &Q) -> Option<(K::Strong, &V)> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn get_both<Q: ?Sized>(&self, key: &Q) -> Option<(K::Strong, &V)> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns a pair of a strong reference to the key, and a reference to the value, if present.
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns a mutable reference to the value corresponding to the key.
pub fn get_both_mut<Q: ?Sized>(
&mut self,
key: &Q
) -> Option<(K::Strong, &mut V)> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn get_both_mut<Q: ?Sized>(
&mut self,
key: &Q
) -> Option<(K::Strong, &mut V)> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Returns a pair of a strong reference to the key, and a mutable reference to the value, if present.
pub fn insert(&mut self, key: K::Strong, value: V) -> Option<V>
[src]
pub fn insert(&mut self, key: K::Strong, value: V) -> Option<V>
Unconditionally inserts the value, returning the old value if already present.
Unlike std::collections::HashMap
, this replaced the key even if occupied.
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
[src]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where
Q: Hash + Eq,
K::Key: Borrow<Q>,
Removes the entry with the given key, if it exists, and returns the value.
pub fn retain<F>(&mut self, f: F) where
F: FnMut(K::Strong, &mut V) -> bool,
[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(K::Strong, &mut V) -> bool,
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakKeyHashMap<K, V1, S1>,
value_equal: F
) -> bool where
F: FnMut(&V, &V1) -> bool,
S1: BuildHasher,
[src]
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakKeyHashMap<K, V1, S1>,
value_equal: F
) -> bool where
F: FnMut(&V, &V1) -> bool,
S1: BuildHasher,
Is this map a submap of the other, using the given value comparison.
In particular, all the keys of self
must be in other
and the values must compare
true
with value_equal
.
pub fn is_submap<V1, S1>(&self, other: &WeakKeyHashMap<K, V1, S1>) -> bool where
V: PartialEq<V1>,
S1: BuildHasher,
[src]
pub fn is_submap<V1, S1>(&self, other: &WeakKeyHashMap<K, V1, S1>) -> bool where
V: PartialEq<V1>,
S1: BuildHasher,
Is self
a submap of other
?
pub fn domain_is_subset<V1, S1>(
&self,
other: &WeakKeyHashMap<K, V1, S1>
) -> bool where
S1: BuildHasher,
[src]
pub fn domain_is_subset<V1, S1>(
&self,
other: &WeakKeyHashMap<K, V1, S1>
) -> bool where
S1: BuildHasher,
Are the keys of self
a subset of the keys of other
?
impl<K: WeakElement, V, S> WeakKeyHashMap<K, V, S>
[src]
impl<K: WeakElement, V, S> WeakKeyHashMap<K, V, S>
ⓘImportant traits for Iter<'a, K, V>pub fn iter(&self) -> Iter<K, V>
[src]
pub fn iter(&self) -> Iter<K, V>
Gets an iterator over the keys and values.
ⓘImportant traits for Keys<'a, K, V>pub fn keys(&self) -> Keys<K, V>
[src]
pub fn keys(&self) -> Keys<K, V>
Gets an iterator over the keys.
ⓘImportant traits for Values<'a, K, V>pub fn values(&self) -> Values<K, V>
[src]
pub fn values(&self) -> Values<K, V>
Gets an iterator over the values.
ⓘImportant traits for IterMut<'a, K, V>pub fn iter_mut(&mut self) -> IterMut<K, V>
[src]
pub fn iter_mut(&mut self) -> IterMut<K, V>
Gets an iterator over the keys and mutable values.
ⓘImportant traits for ValuesMut<'a, K, V>pub fn values_mut(&mut self) -> ValuesMut<K, V>
[src]
pub fn values_mut(&mut self) -> ValuesMut<K, V>
Gets an iterator over the mutable values.
ⓘImportant traits for Drain<'a, K, V>pub fn drain(&mut self) -> Drain<K, V>
[src]
pub fn drain(&mut self) -> Drain<K, V>
Gets a draining iterator, which removes all the values but retains the storage.
Trait Implementations
impl<K, V, V1, S, S1> PartialEq<WeakKeyHashMap<K, V1, S1>> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
V: PartialEq<V1>,
S: BuildHasher,
S1: BuildHasher,
[src]
impl<K, V, V1, S, S1> PartialEq<WeakKeyHashMap<K, V1, S1>> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
V: PartialEq<V1>,
S: BuildHasher,
S1: BuildHasher,
fn eq(&self, other: &WeakKeyHashMap<K, V1, S1>) -> bool
[src]
fn eq(&self, other: &WeakKeyHashMap<K, V1, S1>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<K: WeakKey, V: Eq, S: BuildHasher> Eq for WeakKeyHashMap<K, V, S>
[src]
impl<K: WeakKey, V: Eq, S: BuildHasher> Eq for WeakKeyHashMap<K, V, S>
impl<K: WeakKey, V, S: BuildHasher + Default> Default for WeakKeyHashMap<K, V, S>
[src]
impl<K: WeakKey, V, S: BuildHasher + Default> Default for WeakKeyHashMap<K, V, S>
impl<'a, K, V, S, Q: ?Sized> Index<&'a Q> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
K::Key: Borrow<Q>,
S: BuildHasher,
Q: Eq + Hash,
[src]
impl<'a, K, V, S, Q: ?Sized> Index<&'a Q> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
K::Key: Borrow<Q>,
S: BuildHasher,
Q: Eq + Hash,
type Output = V
The returned type after indexing.
fn index(&self, index: &'a Q) -> &Self::Output
[src]
fn index(&self, index: &'a Q) -> &Self::Output
Performs the indexing (container[index]
) operation.
impl<'a, K, V, S, Q: ?Sized> IndexMut<&'a Q> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
K::Key: Borrow<Q>,
S: BuildHasher,
Q: Eq + Hash,
[src]
impl<'a, K, V, S, Q: ?Sized> IndexMut<&'a Q> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
K::Key: Borrow<Q>,
S: BuildHasher,
Q: Eq + Hash,
fn index_mut(&mut self, index: &'a Q) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: &'a Q) -> &mut Self::Output
Performs the mutable indexing (container[index]
) operation.
impl<K, V, S> FromIterator<(K::Strong, V)> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
S: BuildHasher + Default,
[src]
impl<K, V, S> FromIterator<(K::Strong, V)> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
S: BuildHasher + Default,
fn from_iter<T: IntoIterator<Item = (K::Strong, V)>>(iter: T) -> Self
[src]
fn from_iter<T: IntoIterator<Item = (K::Strong, V)>>(iter: T) -> Self
Creates a value from an iterator. Read more
impl<K, V, S> Extend<(K::Strong, V)> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
S: BuildHasher,
[src]
impl<K, V, S> Extend<(K::Strong, V)> for WeakKeyHashMap<K, V, S> where
K: WeakKey,
S: BuildHasher,
fn extend<T: IntoIterator<Item = (K::Strong, V)>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = (K::Strong, V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
impl<'a, K, V, S> Extend<(&'a K::Strong, &'a V)> for WeakKeyHashMap<K, V, S> where
K: 'a + WeakKey,
K::Strong: Clone,
V: 'a + Clone,
S: BuildHasher,
[src]
impl<'a, K, V, S> Extend<(&'a K::Strong, &'a V)> for WeakKeyHashMap<K, V, S> where
K: 'a + WeakKey,
K::Strong: Clone,
V: 'a + Clone,
S: BuildHasher,
fn extend<T: IntoIterator<Item = (&'a K::Strong, &'a V)>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = (&'a K::Strong, &'a V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
impl<K: WeakElement, V: Debug, S> Debug for WeakKeyHashMap<K, V, S> where
K::Strong: Debug,
[src]
impl<K: WeakElement, V: Debug, S> Debug for WeakKeyHashMap<K, V, S> where
K::Strong: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<K: WeakElement, V, S> IntoIterator for WeakKeyHashMap<K, V, S>
[src]
impl<K: WeakElement, V, S> IntoIterator for WeakKeyHashMap<K, V, S>
type Item = (K::Strong, V)
The type of the elements being iterated over.
type IntoIter = IntoIter<K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, K: WeakElement, V, S> IntoIterator for &'a WeakKeyHashMap<K, V, S>
[src]
impl<'a, K: WeakElement, V, S> IntoIterator for &'a WeakKeyHashMap<K, V, S>
type Item = (K::Strong, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, K: WeakElement, V, S> IntoIterator for &'a mut WeakKeyHashMap<K, V, S>
[src]
impl<'a, K: WeakElement, V, S> IntoIterator for &'a mut WeakKeyHashMap<K, V, S>
type Item = (K::Strong, &'a mut V)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<K: Clone, V: Clone, S: Clone> Clone for WeakKeyHashMap<K, V, S>
[src]
impl<K: Clone, V: Clone, S: Clone> Clone for WeakKeyHashMap<K, V, S>
fn clone(&self) -> WeakKeyHashMap<K, V, S>
[src]
fn clone(&self) -> WeakKeyHashMap<K, V, S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<K, V, S> Send for WeakKeyHashMap<K, V, S> where
K: Send,
S: Send,
V: Send,
impl<K, V, S> Send for WeakKeyHashMap<K, V, S> where
K: Send,
S: Send,
V: Send,
impl<K, V, S> Sync for WeakKeyHashMap<K, V, S> where
K: Sync,
S: Sync,
V: Sync,
impl<K, V, S> Sync for WeakKeyHashMap<K, V, S> where
K: Sync,
S: Sync,
V: Sync,