[−][src]Struct weak_table::WeakHashSet
A hash set with weak elements, hashed on element value.
When a weak pointer expires, its mapping is lazily removed.
Implementations
impl<T: WeakKey> WeakHashSet<T, RandomState>
[src]
pub fn new() -> Self
[src]
Creates an empty WeakHashSet
.
pub fn with_capacity(capacity: usize) -> Self
[src]
Creates an empty WeakHashSet
with the given capacity.
impl<T: WeakKey, S: BuildHasher> WeakHashSet<T, S>
[src]
pub fn with_hasher(hash_builder: S) -> Self
[src]
Creates an empty WeakHashSet
with the given capacity and hasher.
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
[src]
Creates an empty WeakHashSet
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 set empty?
Note that this may return false even if all keys in the set 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 elements.
pub fn clear(&mut self)
[src]
Removes all associations from the map.
pub fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
Q: Eq + Hash,
T::Key: Borrow<Q>,
[src]
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]
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]
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]
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]
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]
S1: BuildHasher,
Is self a subset of other?
impl<T: WeakKey, S> WeakHashSet<T, S>
[src]
pub fn iter(&self) -> Iter<T>
[src]
Gets an iterator over the keys and values.
pub fn drain(&mut self) -> Drain<T>
[src]
Gets a draining iterator, which removes all the values but retains the storage.
Trait Implementations
impl<T: Clone, S: Clone> Clone for WeakHashSet<T, S>
[src]
fn clone(&self) -> WeakHashSet<T, S>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: WeakKey, S> Debug for WeakHashSet<T, S> where
T::Strong: Debug,
[src]
T::Strong: Debug,
impl<T: WeakKey, S: BuildHasher + Default> Default for WeakHashSet<T, S>
[src]
impl<T: WeakKey, S: BuildHasher> Eq for WeakHashSet<T, S> where
T::Key: Eq,
[src]
T::Key: Eq,
impl<T: WeakKey, S: BuildHasher> Extend<<T as WeakElement>::Strong> for WeakHashSet<T, S>
[src]
fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T, S> FromIterator<<T as WeakElement>::Strong> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher + Default,
[src]
T: WeakKey,
S: BuildHasher + Default,
fn from_iter<I: IntoIterator<Item = T::Strong>>(iter: I) -> Self
[src]
impl<T: WeakKey, S> IntoIterator for WeakHashSet<T, S>
[src]
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]
impl<'a, T: WeakKey, S> IntoIterator for &'a WeakHashSet<T, S>
[src]
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]
impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher,
S1: BuildHasher,
[src]
T: WeakKey,
S: BuildHasher,
S1: BuildHasher,
Auto Trait Implementations
impl<T, S> RefUnwindSafe for WeakHashSet<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for WeakHashSet<T, S> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<T, S> Sync for WeakHashSet<T, S> where
S: Sync,
T: Sync,
S: Sync,
T: Sync,
impl<T, S> Unpin for WeakHashSet<T, S> where
S: Unpin,
S: Unpin,
impl<T, S> UnwindSafe for WeakHashSet<T, S> where
S: UnwindSafe,
T: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,