pub struct Set<T, H = RandomState> { /* private fields */ }
Expand description
A lock-free set. This is currently implemented on top of
Map
. To check more details about it, please see Map
docs.
Implementations
sourceimpl<T> Set<T>
impl<T> Set<T>
sourcepub fn with_incin(incin: SharedIncin<T>) -> Self
pub fn with_incin(incin: SharedIncin<T>) -> Self
Creates the Set
using the given shared incinerator.
sourceimpl<T, H> Set<T, H>where
H: BuildHasher,
impl<T, H> Set<T, H>where
H: BuildHasher,
sourcepub fn with_hasher(builder: H) -> Self
pub fn with_hasher(builder: H) -> Self
Creates a Set
with the given hasher builder.
sourcepub fn with_hasher_and_incin(builder: H, incin: SharedIncin<T>) -> Self
pub fn with_hasher_and_incin(builder: H, incin: SharedIncin<T>) -> Self
Creates the Set
using the given hasher builder and shared
incinerator.
sourcepub fn incin(&self) -> SharedIncin<T>
pub fn incin(&self) -> SharedIncin<T>
The shared incinerator used by this Map
.
sourcepub fn optimize_space(&mut self)
pub fn optimize_space(&mut self)
Tries to optimize space by removing unnecessary tables without removing any element. This method cannot be performed in a shared context.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all elements. This method cannot be performed in a shared context.
sourcepub fn get<'set, U>(&'set self, elem: &U) -> Option<ReadGuard<'set, T>>where
U: Hash + Ord,
T: Borrow<U>,
pub fn get<'set, U>(&'set self, elem: &U) -> Option<ReadGuard<'set, T>>where
U: Hash + Ord,
T: Borrow<U>,
Returns a guarded reference to the given element in the Set
. This
may be useful for types with additional metadata. The method accepts
a type resulted from borrowing the stored element. This method will
only work correctly if Hash
and Ord
are implemented in the same
way for the borrowed type and the stored type. If the element is not
found, None
is obviously returned.
sourcepub fn insert_with<F>(&self, elem: T, interactive: F) -> Insertion<T, T>where
F: FnMut(&T, Option<&T>) -> bool,
T: Hash + Ord,
pub fn insert_with<F>(&self, elem: T, interactive: F) -> Insertion<T, T>where
F: FnMut(&T, Option<&T>) -> bool,
T: Hash + Ord,
Inserts interactively the element into the Set
. A passed closure
tests if the insertion should proceed. The first argument of the
closure is the element passed to insert_with
and the second is the
stored found element, if any. The closure returns whether the insertion
should go on. This method is useful for types with metadata.
sourcepub fn reinsert(&self, elem: Removed<T>) -> Result<(), Removed<T>>where
T: Hash + Ord,
pub fn reinsert(&self, elem: Removed<T>) -> Result<(), Removed<T>>where
T: Hash + Ord,
Tries to reinsert a previously removed element. The element must have been either:
- Removed from this very
Set
. - Removed from an already dead
Set
. - Removed from a
Set
which has no sensitive reads active.
If the removed element does not fit any category, the insertion will fail. Otherwise, insertion cannot fail.
sourcepub fn reinsert_with<F>(
&self,
elem: Removed<T>,
interactive: F
) -> Insertion<T, Removed<T>>where
F: FnMut(&T, Option<&T>) -> bool,
T: Hash + Ord,
pub fn reinsert_with<F>(
&self,
elem: Removed<T>,
interactive: F
) -> Insertion<T, Removed<T>>where
F: FnMut(&T, Option<&T>) -> bool,
T: Hash + Ord,
Tries to reinsert interactively a previously removed element. A closure is passed to test if the reinsertion should proceed The first argument to the closure is a reference to the given element and the second is a reference to the found stored element, if any. The closure returns whether the reinsertion should go on. The removed element must have been either:
- Removed from this very
Set
. - Removed from an already dead
Set
. - Removed from a
Set
which has no sensitive reads active.
If the removed element does not fit any category, the insertion will fail. Otherwise, insertion cannot fail.
sourcepub fn remove_with<U, F>(&self, elem: &U, interactive: F) -> Option<Removed<T>>where
U: Hash + Ord,
T: Borrow<U>,
F: FnMut(&T) -> bool,
pub fn remove_with<U, F>(&self, elem: &U, interactive: F) -> Option<Removed<T>>where
U: Hash + Ord,
T: Borrow<U>,
F: FnMut(&T) -> bool,
Removes interactively the given element. A closure is passed to
validate the removal. The only argument passed to the closure is a
reference to the found stored element. The return value is whether the
removal should happen or not. The method accepts a type resulted from
borrowing the stored element. This method will only work correctly
if Hash
and Ord
are implemented in the same way for the borrowed
type and the stored type.
sourcepub fn extend<I>(&self, iterable: I)where
I: IntoIterator<Item = T>,
T: Hash + Ord,
pub fn extend<I>(&self, iterable: I)where
I: IntoIterator<Item = T>,
T: Hash + Ord,
Acts just like Extend::extend
but does not require mutability.
Trait Implementations
sourceimpl<T, H> Default for Set<T, H>where
H: BuildHasher + Default,
impl<T, H> Default for Set<T, H>where
H: BuildHasher + Default,
sourceimpl<T, H> Extend<T> for Set<T, H>where
H: BuildHasher,
T: Hash + Ord,
impl<T, H> Extend<T> for Set<T, H>where
H: BuildHasher,
T: Hash + Ord,
sourcefn extend<I>(&mut self, iterable: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iterable: I)where
I: IntoIterator<Item = T>,
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)