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

impl<K, V> WeakValueHashMap<K, V, RandomState> where
    K: Eq + Hash,
    V: WeakElement
[src]

pub fn new() -> WeakValueHashMap<K, V, RandomState>[src]

Creates an empty WeakValueHashMap.

pub fn with_capacity(capacity: usize) -> WeakValueHashMap<K, V, RandomState>[src]

Creates an empty WeakValueHashMap with the given capacity.

impl<K, V, S> WeakValueHashMap<K, V, S> where
    S: BuildHasher,
    K: Eq + Hash,
    V: WeakElement
[src]

pub fn with_hasher(hash_builder: S) -> WeakValueHashMap<K, V, S>[src]

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>
[src]

Creates an empty WeakValueHashMap with the given capacity and hasher.

pub fn hasher(&self) -> &S[src]

Returns a reference to the map’s BuildHasher.

pub fn capacity(&self) -> usize[src]

Returns the number of elements the map can hold without reallocating.

pub fn remove_expired(&mut self)[src]

Removes all mappings whose keys have expired.

pub fn reserve(&mut self, additional_capacity: usize)[src]

Reserves room for additional elements.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity to the minimum allowed to hold the current number of elements.

pub fn len(&self) -> usize[src]

Returns an over-approximation of the number of elements.

pub fn is_empty(&self) -> bool[src]

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]

The proportion of buckets that are used.

This is an over-approximation because of expired keys.

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>[src]

Gets the requested entry.

pub fn clear(&mut self)[src]

Removes all associations from the map.

pub fn get<Q>(&self, key: &Q) -> Option<<V as WeakElement>::Strong> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
[src]

Returns a reference to the value corresponding to the key.

pub fn contains_key<Q>(&self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
[src]

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>
[src]

Unconditionally inserts the value, returning the old value if already present.

Like std::collections::HashMap, this does not replace the key if occupied.

pub fn remove<Q>(&mut self, key: &Q) -> Option<<V as WeakElement>::Strong> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
[src]

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, <V as WeakElement>::Strong) -> bool
[src]

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
[src]

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>, 
[src]

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
[src]

Are the keys of self a subset of the keys of other?

impl<K, V, S> WeakValueHashMap<K, V, S> where
    V: WeakElement
[src]

pub fn iter(&self) -> Iter<'_, K, V>

Notable traits for Iter<'a, K, V>

impl<'a, K, V> Iterator for Iter<'a, K, V> where
    V: WeakElement
type Item = (&'a K, <V as WeakElement>::Strong);
[src]

Gets an iterator over the keys and values.

pub fn keys(&self) -> Keys<'_, K, V>

Notable traits for Keys<'a, K, V>

impl<'a, K, V> Iterator for Keys<'a, K, V> where
    V: WeakElement
type Item = &'a K;
[src]

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;
[src]

Gets an iterator over the values.

pub fn drain(&mut self) -> Drain<'_, K, V>

Notable traits for Drain<'a, K, V>

impl<'a, K, V> Iterator for Drain<'a, K, V> where
    V: WeakElement
type Item = (K, <V as WeakElement>::Strong);
[src]

Gets a draining iterator, which removes all the values but retains the storage.

Trait Implementations

impl<K, V, S> Clone for WeakValueHashMap<K, V, S> where
    S: Clone,
    K: Clone,
    V: Clone
[src]

pub fn clone(&self) -> WeakValueHashMap<K, V, S>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K, V, S> Debug for WeakValueHashMap<K, V, S> where
    K: Debug,
    V: WeakElement,
    <V as WeakElement>::Strong: Debug
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<K, V, S> Default for WeakValueHashMap<K, V, S> where
    S: BuildHasher + Default,
    K: Eq + Hash,
    V: WeakElement
[src]

pub fn default() -> WeakValueHashMap<K, V, S>[src]

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
[src]

pub fn extend<T>(&mut self, iter: T) where
    T: IntoIterator<Item = (&'a K, &'a <V as WeakElement>::Strong)>, 
[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (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
[src]

pub fn extend<T>(&mut self, iter: T) where
    T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>, 
[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (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
[src]

pub fn from_iter<T>(iter: T) -> WeakValueHashMap<K, V, S> where
    T: IntoIterator<Item = (K, <V as WeakElement>::Strong)>, 
[src]

Creates a value from an iterator. Read more

impl<K, V, S> IntoIterator for WeakValueHashMap<K, V, S> where
    V: WeakElement
[src]

type Item = (K, <V as WeakElement>::Strong)

The type of the elements being iterated over.

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <WeakValueHashMap<K, V, S> as IntoIterator>::IntoIter[src]

Creates an iterator from a value. Read more

impl<'a, K, V, S> IntoIterator for &'a WeakValueHashMap<K, V, S> where
    V: WeakElement
[src]

type Item = (&'a K, <V as WeakElement>::Strong)

The type of the elements being iterated over.

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?

pub fn into_iter(
    self
) -> <&'a WeakValueHashMap<K, V, S> as IntoIterator>::IntoIter
[src]

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>, 
[src]

pub fn eq(&self, other: &WeakValueHashMap<K, V1, S1>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<K, V, S> Eq for WeakValueHashMap<K, V, S> where
    S: BuildHasher,
    K: Eq + Hash,
    V: WeakElement,
    <V as WeakElement>::Strong: Eq
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

pub fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

pub fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.

impl<T> ToImpl for T[src]

fn to<P>(self) -> P where
    Self: Into<P>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.