pub struct PtrWeakHashSet<T, S = RandomState>(/* private fields */);
Expand description
A hash set with weak elements, hashed on element pointer.
When a weak pointer expires, its mapping is lazily removed.
Implementations§
Source§impl<T: WeakElement> PtrWeakHashSet<T, RandomState>
impl<T: WeakElement> PtrWeakHashSet<T, RandomState>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty PtrWeakHashSet
with the given capacity.
O(n) time
Source§impl<T: WeakElement, S: BuildHasher> PtrWeakHashSet<T, S>
impl<T: WeakElement, S: BuildHasher> PtrWeakHashSet<T, S>
Sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates an empty PtrWeakHashSet
with the given capacity and hasher.
O(n) time
Sourcepub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates an empty PtrWeakHashSet
with the given capacity and hasher.
O(n) time
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
O(1) time
Sourcepub fn remove_expired(&mut self)
pub fn remove_expired(&mut self)
Removes all mappings whose keys have expired.
O(n) time
Sourcepub fn reserve(&mut self, additional_capacity: usize)
pub fn reserve(&mut self, additional_capacity: usize)
Reserves room for additional elements.
O(n) time
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity to the minimum allowed to hold the current number of elements.
O(n) time
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is the set known to be empty?
This could answer false
for an empty set whose elements have
expired but have yet to be collected.
O(1) time
Sourcepub fn load_factor(&self) -> f32
pub fn load_factor(&self) -> f32
The proportion of buckets that are used.
This is an over-approximation because of expired elements.
O(1) time
Sourcepub fn contains(&self, key: &T::Strong) -> bool
pub fn contains(&self, key: &T::Strong) -> bool
Returns true if the map contains the specified key.
expected O(1) time; worst-case O(p) time
Sourcepub fn insert(&mut self, key: T::Strong) -> bool
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.
expected O(1) time; worst-case O(p) time
Sourcepub fn remove(&mut self, key: &T::Strong) -> bool
pub fn remove(&mut self, key: &T::Strong) -> bool
Removes the entry with the given key, if it exists, and returns the value.
expected O(1) time; worst-case O(p) time
Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
O(n) time
Sourcepub fn is_subset<S1>(&self, other: &PtrWeakHashSet<T, S1>) -> boolwhere
S1: BuildHasher,
pub fn is_subset<S1>(&self, other: &PtrWeakHashSet<T, S1>) -> boolwhere
S1: BuildHasher,
Is self a subset of other?
expected O(n) time; worst-case O(nq) time (where n is
self.capacity()
and q is the length of the probe sequences
in other
)
Source§impl<T: WeakElement, S> PtrWeakHashSet<T, S>
impl<T: WeakElement, S> PtrWeakHashSet<T, S>
Trait Implementations§
Source§impl<T: Clone, S: Clone> Clone for PtrWeakHashSet<T, S>
impl<T: Clone, S: Clone> Clone for PtrWeakHashSet<T, S>
Source§fn clone(&self) -> PtrWeakHashSet<T, S>
fn clone(&self) -> PtrWeakHashSet<T, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T, S> Debug for PtrWeakHashSet<T, S>
impl<T, S> Debug for PtrWeakHashSet<T, S>
Source§impl<T: WeakElement, S: BuildHasher + Default> Default for PtrWeakHashSet<T, S>
impl<T: WeakElement, S: BuildHasher + Default> Default for PtrWeakHashSet<T, S>
Source§impl<T, S> Extend<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S>
impl<T, S> Extend<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S>
Source§fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)