[][src]Struct weak_table::WeakWeakHashMap

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

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

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

Implementations

impl<K: WeakKey, V: WeakElement> WeakWeakHashMap<K, V, RandomState>[src]

pub fn new() -> Self[src]

Creates an empty WeakWeakHashMap.

pub fn with_capacity(capacity: usize) -> Self[src]

Creates an empty WeakWeakHashMap with the given capacity.

impl<K: WeakKey, V: WeakElement, S: BuildHasher> WeakWeakHashMap<K, V, S>[src]

pub fn with_hasher(hash_builder: S) -> Self[src]

Creates an empty WeakWeakHashMap with the given capacity and hasher.

pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self[src]

Creates an empty WeakWeakHashMap 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::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: ?Sized>(&self, key: &Q) -> Option<V::Strong> where
    Q: Hash + Eq,
    K::Key: Borrow<Q>, 
[src]

Returns a reference to the value corresponding to the key.

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

Returns the strong reference to the key, if present.

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

Returns strong references to both the key and the value, if present.

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

Returns true if the map contains the specified key.

pub fn insert(&mut self, key: K::Strong, value: V::Strong) -> Option<V::Strong>[src]

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

Unlike std::collections::HashMap, this replaces the key even if occupied.

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

Is self a submap of other?

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

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

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

pub fn iter(&self) -> Iter<K, V>[src]

Gets an iterator over the keys and values.

pub fn keys(&self) -> Keys<K, V>[src]

Gets an iterator over the keys.

pub fn values(&self) -> Values<K, V>[src]

Gets an iterator over the values.

pub fn drain(&mut self) -> Drain<K, V>[src]

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

Trait Implementations

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

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

impl<K: WeakKey, V: WeakElement, S: BuildHasher + Default> Default for WeakWeakHashMap<K, V, S>[src]

impl<K: WeakKey, V: WeakElement, S: BuildHasher> Eq for WeakWeakHashMap<K, V, S> where
    V::Strong: Eq
[src]

impl<K, V, S> Extend<(<K as WeakElement>::Strong, <V as WeakElement>::Strong)> for WeakWeakHashMap<K, V, S> where
    K: WeakKey,
    V: WeakElement,
    S: BuildHasher
[src]

impl<K, V, S> FromIterator<(<K as WeakElement>::Strong, <V as WeakElement>::Strong)> for WeakWeakHashMap<K, V, S> where
    K: WeakKey,
    V: WeakElement,
    S: BuildHasher + Default
[src]

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

type Item = (K::Strong, V::Strong)

The type of the elements being iterated over.

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?

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

type Item = (K::Strong, V::Strong)

The type of the elements being iterated over.

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

Which kind of iterator are we turning this into?

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

Auto Trait Implementations

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

impl<K, V, S> Send for WeakWeakHashMap<K, V, S> where
    K: Send,
    S: Send,
    V: Send

impl<K, V, S> Sync for WeakWeakHashMap<K, V, S> where
    K: Sync,
    S: Sync,
    V: Sync

impl<K, V, S> Unpin for WeakWeakHashMap<K, V, S> where
    S: Unpin

impl<K, V, S> UnwindSafe for WeakWeakHashMap<K, V, S> where
    K: UnwindSafe,
    S: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.