Struct weak_table::WeakHashSet [] [src]

pub struct WeakHashSet<T, S = RandomState>(_);

A hash set with weak elements, hashed on element value.

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

Methods

impl<T: WeakKey> WeakHashSet<T, RandomState>
[src]

Creates an empty WeakHashSet.

Creates an empty WeakHashSet with the given capacity.

impl<T: WeakKey, S: BuildHasher> WeakHashSet<T, S>
[src]

Creates an empty WeakHashSet with the given capacity and hasher.

Creates an empty WeakHashSet with the given capacity and hasher.

Returns a reference to the map's BuildHasher.

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

Removes all mappings whose keys have expired.

Reserves room for additional elements.

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

Returns an over-approximation of the number of elements.

The proportion of buckets that are used.

This is an over-approximation because of expired elements.

Removes all associations from the map.

Returns true if the map contains the specified key.

Gets a strong reference to the given key, if found.

Examples

use weak_table::WeakHashSet;
use std::rc::{Rc, Weak};
use std::ops::Deref;

let mut set: WeakHashSet<Weak<String>> = WeakHashSet::new();

let a = Rc::new("a".to_owned());
set.insert(a.clone());

let also_a = set.get("a").unwrap();

assert!(Rc::ptr_eq( &a, &also_a ));

Unconditionally inserts the value, returning the old value if already present. Does not replace the key.

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.

Is self a subset of other?

impl<T: WeakKey, S> WeakHashSet<T, S>
[src]

Important traits for Iter<'a, T>

Gets an iterator over the keys and values.

Important traits for Drain<'a, T>

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

Trait Implementations

impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher,
    S1: BuildHasher
[src]

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

This method tests for !=.

impl<T: WeakKey, S: BuildHasher> Eq for WeakHashSet<T, S> where
    T::Key: Eq
[src]

impl<T: WeakKey, S: BuildHasher + Default> Default for WeakHashSet<T, S>
[src]

Returns the "default value" for a type. Read more

impl<T, S> FromIterator<T::Strong> for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher + Default
[src]

Creates a value from an iterator. Read more

impl<T: WeakKey, S: BuildHasher> Extend<T::Strong> for WeakHashSet<T, S>
[src]

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

impl<T: WeakKey, S> Debug for WeakHashSet<T, S> where
    T::Strong: Debug
[src]

Formats the value using the given formatter. Read more

impl<T: WeakKey, S> IntoIterator for WeakHashSet<T, S>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<'a, T: WeakKey, S> IntoIterator for &'a WeakHashSet<T, S>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<T: Clone, S: Clone> Clone for WeakHashSet<T, S>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<T, S> Send for WeakHashSet<T, S> where
    S: Send,
    T: Send

impl<T, S> Sync for WeakHashSet<T, S> where
    S: Sync,
    T: Sync