Struct weak_table::WeakValueHashMap [−][src]
pub struct WeakValueHashMap<K, V, S = RandomState> { /* fields omitted */ }
Expand description
A hash map with weak values.
When a weak pointer expires, its mapping is lazily removed.
Implementations
Creates an empty WeakValueHashMap
with the given capacity.
O(n) time
Creates an empty WeakValueHashMap
with the given capacity and hasher.
O(n) time
Creates an empty WeakValueHashMap
with the given capacity and hasher.
O(n) time
Returns the number of elements the map can hold without reallocating.
O(1) time
Removes all mappings whose keys have expired.
O(n) time
Reserves room for additional elements.
O(n) time
Shrinks the capacity to the minimum allowed to hold the current number of elements.
O(n) time
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.
O(1) time
The proportion of buckets that are used.
This is an over-approximation because of expired keys.
O(1) time
Gets the requested entry.
expected O(1) time; worst-case O(p) time
Returns a reference to the value corresponding to the key.
expected O(1) time; worst-case O(p) time
Returns true if the map contains the specified key.
expected O(1) time; worst-case O(p) time
Unconditionally inserts the value, returning the old value if already present.
Like std::collections::HashMap
, this does not replace the key if occupied.
expected O(1) time; worst-case O(p) time
Removes the entry with the given key, if it exists, and returns the value.
expected O(1) time; worst-case O(p) time
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
O(n) time
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakValueHashMap<K, V1, S1>,
value_equal: F
) -> bool where
V1: WeakElement,
F: FnMut(V::Strong, V1::Strong) -> bool,
S1: BuildHasher,
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakValueHashMap<K, V1, S1>,
value_equal: F
) -> bool where
V1: WeakElement,
F: FnMut(V::Strong, V1::Strong) -> 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
.
expected O(n) time; worst-case O(nq) time (where n is
self.capacity()
and q is the length of the probe sequences
in other
)
pub fn is_submap<V1, S1>(&self, other: &WeakValueHashMap<K, V1, S1>) -> bool where
V1: WeakElement,
V::Strong: PartialEq<V1::Strong>,
S1: BuildHasher,
pub fn is_submap<V1, S1>(&self, other: &WeakValueHashMap<K, V1, S1>) -> bool where
V1: WeakElement,
V::Strong: PartialEq<V1::Strong>,
S1: BuildHasher,
Is self
a submap of other
?
expected O(n) time; worst-case O(nq) time (where n is
self.capacity()
and q is the length of the probe sequences
in other
)
pub fn domain_is_subset<V1, S1>(
&self,
other: &WeakValueHashMap<K, V1, S1>
) -> bool where
V1: WeakElement,
S1: BuildHasher,
pub fn domain_is_subset<V1, S1>(
&self,
other: &WeakValueHashMap<K, V1, S1>
) -> bool where
V1: WeakElement,
S1: BuildHasher,
Are the keys of self
a subset of the keys of other
?
expected O(n) time; worst-case O(nq) time (where n is
self.capacity()
and q is the length of the probe sequences
in other
)
Gets an iterator over the keys and values.
O(1) time
Gets an iterator over the keys.
O(1) time
Gets an iterator over the values.
O(1) time
Trait Implementations
impl<K: Eq + Hash, V: WeakElement, S: BuildHasher + Default> Default for WeakValueHashMap<K, V, S>
impl<K: Eq + Hash, V: WeakElement, S: BuildHasher + Default> Default for WeakValueHashMap<K, V, S>
impl<'a, K, V, S> Extend<(&'a K, &'a <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: 'a + Eq + Hash + Clone,
V: 'a + WeakElement,
V::Strong: Clone,
S: BuildHasher,
impl<'a, K, V, S> Extend<(&'a K, &'a <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: 'a + Eq + Hash + Clone,
V: 'a + WeakElement,
V::Strong: Clone,
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
impl<K, V, S> Extend<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
S: BuildHasher,
impl<K, V, S> Extend<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
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
impl<K, V, S> FromIterator<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
S: BuildHasher + Default,
impl<K, V, S> FromIterator<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
S: BuildHasher + Default,
impl<K, V, V1, S, S1> PartialEq<WeakValueHashMap<K, V1, S1>> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
V1: WeakElement,
V::Strong: PartialEq<V1::Strong>,
S: BuildHasher,
S1: BuildHasher,
impl<K, V, V1, S, S1> PartialEq<WeakValueHashMap<K, V1, S1>> for WeakValueHashMap<K, V, S> where
K: Eq + Hash,
V: WeakElement,
V1: WeakElement,
V::Strong: PartialEq<V1::Strong>,
S: BuildHasher,
S1: BuildHasher,
impl<K: Eq + Hash, V: WeakElement, S: BuildHasher> Eq for WeakValueHashMap<K, V, S> where
V::Strong: Eq,
Auto Trait Implementations
impl<K, V, S> RefUnwindSafe for WeakValueHashMap<K, V, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, S> Send for WeakValueHashMap<K, V, S> where
K: Send,
S: Send,
V: Send,
impl<K, V, S> Sync for WeakValueHashMap<K, V, S> where
K: Sync,
S: Sync,
V: Sync,
impl<K, V, S> Unpin for WeakValueHashMap<K, V, S> where
S: Unpin,
impl<K, V, S> UnwindSafe for WeakValueHashMap<K, V, S> where
K: UnwindSafe,
S: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more