Struct enso_prelude::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
.
Creates an empty WeakValueHashMap
with the given capacity.
Creates an empty WeakValueHashMap
with the given capacity and hasher.
pub fn with_capacity_and_hasher(
capacity: usize,
hash_builder: S
) -> WeakValueHashMap<K, V, S>
pub fn with_capacity_and_hasher(
capacity: usize,
hash_builder: S
) -> WeakValueHashMap<K, V, S>
Creates an empty WeakValueHashMap
with the given capacity and hasher.
Returns the number of elements the map can hold without reallocating.
Removes all mappings whose keys have expired.
Shrinks the capacity to the minimum allowed to hold the current number of elements.
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.
The proportion of buckets that are used.
This is an over-approximation because of expired keys.
Returns a reference to the value corresponding to the key.
Returns true if the map contains the specified key.
pub fn insert(
&mut self,
key: K,
value: <V as WeakElement>::Strong
) -> Option<<V as WeakElement>::Strong>
pub fn insert(
&mut self,
key: K,
value: <V as WeakElement>::Strong
) -> Option<<V as WeakElement>::Strong>
Unconditionally inserts the value, returning the old value if already present.
Like std::collections::HashMap
, this does not replace the key if occupied.
Removes the entry with the given key, if it exists, and returns the value.
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakValueHashMap<K, V1, S1>,
value_equal: F
) -> bool where
F: FnMut(<V as WeakElement>::Strong, <V1 as WeakElement>::Strong) -> bool,
V1: WeakElement,
S1: BuildHasher,
pub fn is_submap_with<F, S1, V1>(
&self,
other: &WeakValueHashMap<K, V1, S1>,
value_equal: F
) -> bool where
F: FnMut(<V as WeakElement>::Strong, <V1 as WeakElement>::Strong) -> bool,
V1: WeakElement,
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: &WeakValueHashMap<K, V1, S1>) -> bool where
V1: WeakElement,
S1: BuildHasher,
<V as WeakElement>::Strong: PartialEq<<V1 as WeakElement>::Strong>,
pub fn is_submap<V1, S1>(&self, other: &WeakValueHashMap<K, V1, S1>) -> bool where
V1: WeakElement,
S1: BuildHasher,
<V as WeakElement>::Strong: PartialEq<<V1 as WeakElement>::Strong>,
Is self
a submap of 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
?
Gets an iterator over the keys and values.
Gets an iterator over the keys.
pub fn values(&self) -> Values<'_, K, V>ⓘNotable traits for Values<'a, K, V>impl<'a, K, V> Iterator for Values<'a, K, V> where
V: WeakElement, type Item = <V as WeakElement>::Strong;
pub fn values(&self) -> Values<'_, K, V>ⓘNotable traits for Values<'a, K, V>impl<'a, K, V> Iterator for Values<'a, K, V> where
V: WeakElement, type Item = <V as WeakElement>::Strong;
impl<'a, K, V> Iterator for Values<'a, K, V> where
V: WeakElement, type Item = <V as WeakElement>::Strong;
Gets an iterator over the values.
Trait Implementations
impl<K, V, S> Debug for WeakValueHashMap<K, V, S> where
K: Debug,
V: WeakElement,
<V as WeakElement>::Strong: Debug,
impl<K, V, S> Debug for WeakValueHashMap<K, V, S> where
K: Debug,
V: WeakElement,
<V as WeakElement>::Strong: Debug,
impl<K, V, S> Default for WeakValueHashMap<K, V, S> where
S: BuildHasher + Default,
K: Eq + Hash,
V: WeakElement,
impl<K, V, S> Default for WeakValueHashMap<K, V, S> where
S: BuildHasher + Default,
K: Eq + Hash,
V: WeakElement,
Returns the “default value” for a type. Read more
impl<'a, K, V, S> Extend<(&'a K, &'a <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: 'a + Eq + Hash + Clone,
V: 'a + WeakElement,
<V as WeakElement>::Strong: Clone,
impl<'a, K, V, S> Extend<(&'a K, &'a <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: 'a + Eq + Hash + Clone,
V: 'a + WeakElement,
<V as WeakElement>::Strong: Clone,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (&'a K, &'a <V as WeakElement>::Strong)>,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (&'a K, &'a <V as WeakElement>::Strong)>,
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
S: BuildHasher,
K: Eq + Hash,
V: WeakElement,
impl<K, V, S> Extend<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: Eq + Hash,
V: WeakElement,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>,
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>,
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
S: BuildHasher + Default,
K: Eq + Hash,
V: WeakElement,
impl<K, V, S> FromIterator<(K, <V as WeakElement>::Strong)> for WeakValueHashMap<K, V, S> where
S: BuildHasher + Default,
K: Eq + Hash,
V: WeakElement,
pub fn from_iter<T>(iter: T) -> WeakValueHashMap<K, V, S> where
T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>,
pub fn from_iter<T>(iter: T) -> WeakValueHashMap<K, V, S> where
T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>,
Creates a value from an iterator. Read more
Creates an iterator from a value. Read more
impl<K, V, V1, S, S1> PartialEq<WeakValueHashMap<K, V1, S1>> for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: Eq + Hash,
V: WeakElement,
V1: WeakElement,
S1: BuildHasher,
<V as WeakElement>::Strong: PartialEq<<V1 as WeakElement>::Strong>,
impl<K, V, V1, S, S1> PartialEq<WeakValueHashMap<K, V1, S1>> for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: Eq + Hash,
V: WeakElement,
V1: WeakElement,
S1: BuildHasher,
<V as WeakElement>::Strong: PartialEq<<V1 as WeakElement>::Strong>,
impl<K, V, S> Eq for WeakValueHashMap<K, V, S> where
S: BuildHasher,
K: Eq + Hash,
V: WeakElement,
<V as WeakElement>::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
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.