Struct enso_prelude::WeakKeyHashMap[][src]

pub struct WeakKeyHashMap<K, V, S = RandomState> { /* fields omitted */ }
Expand description

A hash map with weak keys, hashed on key value.

When a weak pointer expires, its mapping is lazily removed.

Implementations

impl<K, V> WeakKeyHashMap<K, V, RandomState> where
    K: WeakKey
[src]

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

Creates an empty WeakKeyHashMap.

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

Creates an empty WeakKeyHashMap with the given capacity.

impl<K, V, S> WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey
[src]

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

Creates an empty WeakKeyHashMap with the given capacity and hasher.

pub fn with_capacity_and_hasher(
    capacity: usize,
    hash_builder: S
) -> WeakKeyHashMap<K, V, S>
[src]

Creates an empty WeakKeyHashMap 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 as WeakElement>::Strong) -> 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> where
    Q: Hash + Eq + ?Sized,
    <K as WeakKey>::Key: Borrow<Q>, 
[src]

Returns a reference to the value corresponding to the key.

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

Returns true if the map contains the specified key.

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

Returns a strong reference to the key, if found.

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

Returns a pair of a strong reference to the key, and a reference to the value, if present.

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

Returns a mutable reference to the value corresponding to the key.

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

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

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>(&mut self, key: &Q) -> Option<V> where
    Q: Hash + Eq + ?Sized,
    <K as WeakKey>::Key: Borrow<Q>, 
[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 as WeakElement>::Strong, &mut V) -> 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: &WeakKeyHashMap<K, V1, S1>,
    value_equal: F
) -> bool where
    F: FnMut(&V, &V1) -> bool,
    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: &WeakKeyHashMap<K, V1, S1>) -> bool where
    V: PartialEq<V1>,
    S1: BuildHasher
[src]

Is self a submap of other?

pub fn domain_is_subset<V1, S1>(
    &self,
    other: &WeakKeyHashMap<K, V1, S1>
) -> bool where
    S1: BuildHasher
[src]

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

impl<K, V, S> WeakKeyHashMap<K, V, S> where
    K: 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
    K: WeakElement
type Item = (<K as WeakElement>::Strong, &'a V);
[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
    K: WeakElement
type Item = <K as WeakElement>::Strong;
[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
    K: WeakElement
type Item = &'a V;
[src]

Gets an iterator over the values.

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

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

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

Gets an iterator over the keys and mutable values.

pub fn values_mut(&mut self) -> ValuesMut<'_, K, V>

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

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

Gets an iterator over the mutable 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
    K: WeakElement
type Item = (<K as WeakElement>::Strong, V);
[src]

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

Trait Implementations

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

pub fn clone(&self) -> WeakKeyHashMap<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 WeakKeyHashMap<K, V, S> where
    K: WeakElement,
    V: Debug,
    <K 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 WeakKeyHashMap<K, V, S> where
    S: BuildHasher + Default,
    K: WeakKey
[src]

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

Returns the “default value” for a type. Read more

impl<'a, K, V, S> Extend<(&'a <K as WeakElement>::Strong, &'a V)> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: 'a + WeakKey,
    V: 'a + Clone,
    <K as WeakElement>::Strong: Clone
[src]

pub fn extend<T>(&mut self, iter: T) where
    T: IntoIterator<Item = (&'a <K as WeakElement>::Strong, &'a V)>, 
[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 as WeakElement>::Strong, V)> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey
[src]

pub fn extend<T>(&mut self, iter: T) where
    T: IntoIterator<Item = (<K as WeakElement>::Strong, V)>, 
[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 as WeakElement>::Strong, V)> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher + Default,
    K: WeakKey
[src]

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

Creates a value from an iterator. Read more

impl<'a, K, V, S, Q> Index<&'a Q> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey,
    Q: Eq + Hash + ?Sized,
    <K as WeakKey>::Key: Borrow<Q>, 
[src]

type Output = V

The returned type after indexing.

pub fn index(
    &self,
    index: &'a Q
) -> &<WeakKeyHashMap<K, V, S> as Index<&'a Q>>::Output
[src]

Performs the indexing (container[index]) operation. Read more

impl<'a, K, V, S, Q> IndexMut<&'a Q> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey,
    Q: Eq + Hash + ?Sized,
    <K as WeakKey>::Key: Borrow<Q>, 
[src]

pub fn index_mut(
    &mut self,
    index: &'a Q
) -> &mut <WeakKeyHashMap<K, V, S> as Index<&'a Q>>::Output
[src]

Performs the mutable indexing (container[index]) operation. Read more

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

type Item = (<K as WeakElement>::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?

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

Creates an iterator from a value. Read more

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

type Item = (<K as WeakElement>::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?

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

Creates an iterator from a value. Read more

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

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

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) -> <WeakKeyHashMap<K, V, S> as IntoIterator>::IntoIter[src]

Creates an iterator from a value. Read more

impl<K, V, V1, S, S1> PartialEq<WeakKeyHashMap<K, V1, S1>> for WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey,
    V: PartialEq<V1>,
    S1: BuildHasher
[src]

pub fn eq(&self, other: &WeakKeyHashMap<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 WeakKeyHashMap<K, V, S> where
    S: BuildHasher,
    K: WeakKey,
    V: Eq
[src]

Auto Trait Implementations

impl<K, V, S> RefUnwindSafe for WeakKeyHashMap<K, V, S> where
    K: RefUnwindSafe,
    S: RefUnwindSafe,
    V: RefUnwindSafe

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> Unpin for WeakKeyHashMap<K, V, S> where
    S: Unpin

impl<K, V, S> UnwindSafe for WeakKeyHashMap<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.