Struct weak_table::PtrWeakHashSet
source · [−]pub struct PtrWeakHashSet<T, S = RandomState>(_);
Expand description
A hash set with weak elements, hashed on element pointer.
When a weak pointer expires, its mapping is lazily removed.
Implementations
sourceimpl<T: WeakElement> PtrWeakHashSet<T, RandomState> where
T::Strong: Deref,
impl<T: WeakElement> PtrWeakHashSet<T, RandomState> where
T::Strong: Deref,
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
sourceimpl<T: WeakElement, S: BuildHasher> PtrWeakHashSet<T, S> where
T::Strong: Deref,
impl<T: WeakElement, S: BuildHasher> PtrWeakHashSet<T, S> where
T::Strong: Deref,
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) where
F: FnMut(T::Strong) -> bool,
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.
O(n) time
sourcepub fn is_subset<S1>(&self, other: &PtrWeakHashSet<T, S1>) -> bool where
S1: BuildHasher,
pub fn is_subset<S1>(&self, other: &PtrWeakHashSet<T, S1>) -> bool where
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
)
sourceimpl<T: WeakElement, S> PtrWeakHashSet<T, S> where
T::Strong: Deref,
impl<T: WeakElement, S> PtrWeakHashSet<T, S> where
T::Strong: Deref,
Trait Implementations
sourceimpl<T: Clone, S: Clone> Clone for PtrWeakHashSet<T, S>
impl<T: Clone, S: Clone> Clone for PtrWeakHashSet<T, S>
sourcefn clone(&self) -> PtrWeakHashSet<T, S>
fn clone(&self) -> PtrWeakHashSet<T, S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T, S> Debug for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Debug,
impl<T, S> Debug for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Debug,
sourceimpl<T: WeakElement, S: BuildHasher + Default> Default for PtrWeakHashSet<T, S> where
T::Strong: Deref,
impl<T: WeakElement, S: BuildHasher + Default> Default for PtrWeakHashSet<T, S> where
T::Strong: Deref,
sourceimpl<T, S> Extend<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher,
impl<T, S> Extend<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher,
sourcefn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T::Strong>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T, S> FromIterator<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher + Default,
impl<T, S> FromIterator<<T as WeakElement>::Strong> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher + Default,
sourcefn from_iter<I: IntoIterator<Item = T::Strong>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T::Strong>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<T: WeakElement, S> IntoIterator for PtrWeakHashSet<T, S>
impl<T: WeakElement, S> IntoIterator for PtrWeakHashSet<T, S>
sourceimpl<'a, T: WeakElement, S> IntoIterator for &'a PtrWeakHashSet<T, S> where
T::Strong: Deref,
impl<'a, T: WeakElement, S> IntoIterator for &'a PtrWeakHashSet<T, S> where
T::Strong: Deref,
sourceimpl<T, S, S1> PartialEq<PtrWeakHashSet<T, S1>> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher,
S1: BuildHasher,
impl<T, S, S1> PartialEq<PtrWeakHashSet<T, S1>> for PtrWeakHashSet<T, S> where
T: WeakElement,
T::Strong: Deref,
S: BuildHasher,
S1: BuildHasher,
impl<T: WeakElement, S: BuildHasher> Eq for PtrWeakHashSet<T, S> where
T::Strong: Deref,
Auto Trait Implementations
impl<T, S> RefUnwindSafe for PtrWeakHashSet<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for PtrWeakHashSet<T, S> where
S: Send,
T: Send,
impl<T, S> Sync for PtrWeakHashSet<T, S> where
S: Sync,
T: Sync,
impl<T, S> Unpin for PtrWeakHashSet<T, S> where
S: Unpin,
impl<T, S> UnwindSafe for PtrWeakHashSet<T, S> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more