pub struct SsoHashSet<T> {
map: SsoHashMap<T, ()>,
}
Expand description
Small-storage-optimized implementation of a set.
Stores elements in a small array up to a certain length
and switches to HashSet
when that length is exceeded.
Fields§
§map: SsoHashMap<T, ()>
Implementations§
Source§impl<T> SsoHashSet<T>
impl<T> SsoHashSet<T>
Sourcepub fn new() -> SsoHashSet<T>
pub fn new() -> SsoHashSet<T>
Creates an empty SsoHashSet
.
Sourcepub fn with_capacity(cap: usize) -> SsoHashSet<T>
pub fn with_capacity(cap: usize) -> SsoHashSet<T>
Creates an empty SsoHashSet
with the specified capacity.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the set can hold without reallocating.
Source§impl<T> SsoHashSet<T>
impl<T> SsoHashSet<T>
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted
in the SsoHashSet
. The collection may reserve more space to avoid
frequent reallocations.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the set as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.
Sourcepub fn take(&mut self, value: &T) -> Option<T>
pub fn take(&mut self, value: &T) -> Option<T>
Removes and returns the value in the set, if any, that is equal to the given one.
Sourcepub fn get(&self, value: &T) -> Option<&T>
pub fn get(&self, value: &T) -> Option<&T>
Returns a reference to the value in the set, if any, that is equal to the given value.
Sourcepub fn insert(&mut self, elem: T) -> bool
pub fn insert(&mut self, elem: T) -> bool
Adds a value to the set.
Returns whether the value was newly inserted. That is:
- If the set did not previously contain this value,
true
is returned. - If the set already contained this value,
false
is returned.
Trait Implementations§
Source§impl<T> Clone for SsoHashSet<T>where
T: Clone,
impl<T> Clone for SsoHashSet<T>where
T: Clone,
Source§fn clone(&self) -> SsoHashSet<T>
fn clone(&self) -> SsoHashSet<T>
Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> Debug for SsoHashSet<T>where
T: Debug,
impl<T> Debug for SsoHashSet<T>where
T: Debug,
Source§impl<T> Default for SsoHashSet<T>
impl<T> Default for SsoHashSet<T>
Source§fn default() -> SsoHashSet<T>
fn default() -> SsoHashSet<T>
Source§impl<'a, T> Extend<&'a T> for SsoHashSet<T>
impl<'a, T> Extend<&'a T> for SsoHashSet<T>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = &'a T>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = &'a T>,
Source§fn extend_one(&mut self, _: &'a T)
fn extend_one(&mut self, _: &'a T)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T> Extend<T> for SsoHashSet<T>
impl<T> Extend<T> for SsoHashSet<T>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T> FromIterator<T> for SsoHashSet<T>
impl<T> FromIterator<T> for SsoHashSet<T>
Source§fn from_iter<I>(iter: I) -> SsoHashSet<T>where
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> SsoHashSet<T>where
I: IntoIterator<Item = T>,
Source§impl<'a, T> IntoIterator for &'a SsoHashSet<T>
impl<'a, T> IntoIterator for &'a SsoHashSet<T>
Auto Trait Implementations§
impl<T> DynSend for SsoHashSet<T>where
T: DynSend,
impl<T> DynSync for SsoHashSet<T>where
T: DynSync,
impl<T> Freeze for SsoHashSet<T>where
T: Freeze,
impl<T> RefUnwindSafe for SsoHashSet<T>where
T: RefUnwindSafe,
impl<T> Send for SsoHashSet<T>where
T: Send,
impl<T> Sync for SsoHashSet<T>where
T: Sync,
impl<T> Unpin for SsoHashSet<T>where
T: Unpin,
impl<T> UnwindSafe for SsoHashSet<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.