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]
impl<T: WeakKey> WeakHashSet<T, RandomState>
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates an empty WeakHashSet
.
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
Creates an empty WeakHashSet
with the given capacity.
impl<T: WeakKey, S: BuildHasher> WeakHashSet<T, S>
[src]
impl<T: WeakKey, S: BuildHasher> WeakHashSet<T, S>
pub fn with_hasher(hash_builder: S) -> Self
[src]
pub fn with_hasher(hash_builder: S) -> Self
Creates an empty WeakHashSet
with the given capacity and hasher.
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
[src]
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates an empty WeakHashSet
with the given capacity and hasher.
pub fn hasher(&self) -> &S
[src]
pub fn hasher(&self) -> &S
Returns a reference to the map's BuildHasher
.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
pub fn remove_expired(&mut self)
[src]
pub fn remove_expired(&mut self)
Removes all mappings whose keys have expired.
pub fn reserve(&mut self, additional_capacity: usize)
[src]
pub fn reserve(&mut self, additional_capacity: usize)
Reserves room for additional elements.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
Shrinks the capacity to the minimum allowed to hold the current number of elements.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns an over-approximation of the number of elements.
pub fn load_factor(&self) -> f32
[src]
pub fn load_factor(&self) -> f32
The proportion of buckets that are used.
This is an over-approximation because of expired elements.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Removes all associations from the map.
pub fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Eq + Hash,
T::Key: Borrow<Q>,
[src]
pub fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Eq + Hash,
T::Key: Borrow<Q>,
Returns true if the map contains the specified key.
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<T::Strong> where
Q: Eq + Hash,
T::Key: Borrow<Q>,
[src]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<T::Strong> where
Q: Eq + Hash,
T::Key: Borrow<Q>,
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 ));
pub fn insert(&mut self, key: T::Strong) -> bool
[src]
pub fn insert(&mut self, key: T::Strong) -> bool
Unconditionally inserts the value, returning the old value if already present. Does not replace the key.
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> bool where
Q: Eq + Hash,
T::Key: Borrow<Q>,
[src]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> bool where
Q: Eq + Hash,
T::Key: Borrow<Q>,
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(T::Strong) -> bool,
[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(T::Strong) -> bool,
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
pub fn is_subset<S1>(&self, other: &WeakHashSet<T, S1>) -> bool where
S1: BuildHasher,
[src]
pub fn is_subset<S1>(&self, other: &WeakHashSet<T, S1>) -> bool where
S1: BuildHasher,
Is self a subset of other?
impl<T: WeakKey, S> WeakHashSet<T, S>
[src]
impl<T: WeakKey, S> WeakHashSet<T, S>
ⓘImportant traits for Iter<'a, T>pub fn iter(&self) -> Iter<T>
[src]
pub fn iter(&self) -> Iter<T>
Gets an iterator over the keys and values.
ⓘImportant traits for Drain<'a, T>pub fn drain(&mut self) -> Drain<T>
[src]
pub fn drain(&mut self) -> Drain<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]
impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher,
S1: BuildHasher,
fn eq(&self, other: &WeakHashSet<T, S1>) -> bool
[src]
fn eq(&self, other: &WeakHashSet<T, S1>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: WeakKey, S: BuildHasher> Eq for WeakHashSet<T, S> where
T::Key: Eq,
[src]
impl<T: WeakKey, S: BuildHasher> Eq for WeakHashSet<T, S> where
T::Key: Eq,
impl<T: WeakKey, S: BuildHasher + Default> Default for WeakHashSet<T, S>
[src]
impl<T: WeakKey, S: BuildHasher + Default> Default for WeakHashSet<T, S>
impl<T, S> FromIterator<T::Strong> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher + Default,
[src]
impl<T, S> FromIterator<T::Strong> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher + Default,
fn from_iter<I: IntoIterator<Item = T::Strong>>(iter: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = T::Strong>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<T: WeakKey, S: BuildHasher> Extend<T::Strong> for WeakHashSet<T, S>
[src]
impl<T: WeakKey, S: BuildHasher> Extend<T::Strong> for WeakHashSet<T, S>
fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
[src]
fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
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]
impl<T: WeakKey, S> Debug for WeakHashSet<T, S> where
T::Strong: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: WeakKey, S> IntoIterator for WeakHashSet<T, S>
[src]
impl<T: WeakKey, S> IntoIterator for WeakHashSet<T, S>
type Item = T::Strong
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, T: WeakKey, S> IntoIterator for &'a WeakHashSet<T, S>
[src]
impl<'a, T: WeakKey, S> IntoIterator for &'a WeakHashSet<T, S>
type Item = T::Strong
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<T: Clone, S: Clone> Clone for WeakHashSet<T, S>
[src]
impl<T: Clone, S: Clone> Clone for WeakHashSet<T, S>
fn clone(&self) -> WeakHashSet<T, S>
[src]
fn clone(&self) -> WeakHashSet<T, S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
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> Send for WeakHashSet<T, S> where
S: Send,
T: Send,
impl<T, S> Sync for WeakHashSet<T, S> where
S: Sync,
T: Sync,
impl<T, S> Sync for WeakHashSet<T, S> where
S: Sync,
T: Sync,