pub struct SmallSet<T, const N: usize>(/* private fields */);Expand description
A hash set, with a fast non-cryptographic hasher and deterministic iteration order, optimized for the common case of very few elements.
Up to N entries are stored inline, in a flat, linearly-scanned
array, with no heap allocation and no hashing. Once an insert
grows the set past N entries, it transparently and permanently
promotes itself to an ISet
Implementations§
Source§impl<T, const N: usize> SmallSet<T, N>
impl<T, const N: usize> SmallSet<T, N>
Sourcepub fn new() -> SmallSet<T, N>
pub fn new() -> SmallSet<T, N>
Creates an empty SmallSet. Does not allocate until it grows
past N elements.
Sourcepub fn is_inline(&self) -> bool
pub fn is_inline(&self) -> bool
Returns true if this set has not (yet) grown past N
elements, i.e., is still using inline, non-heap-allocated
storage.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the set, removing all values. A previously promoted set stays promoted; see the SmallMap documentation.
Source§impl<T, const N: usize> SmallSet<T, N>
impl<T, const N: usize> SmallSet<T, N>
Sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds a value to the set.
If the set did not have this value present, true is
returned. If the set did have this value present, false is
returned.
Trait Implementations§
impl<T, const N: usize> Eq for SmallSet<T, N>
Source§impl<T, const N: usize> Extend<T> for SmallSet<T, N>
impl<T, const N: usize> Extend<T> for SmallSet<T, N>
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: 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)Source§impl<T, const N: usize> FromIterator<T> for SmallSet<T, N>
impl<T, const N: usize> FromIterator<T> for SmallSet<T, N>
Source§impl<T, const N: usize> IntoIterator for SmallSet<T, N>
impl<T, const N: usize> IntoIterator for SmallSet<T, N>
Source§impl<'a, T, const N: usize> IntoIterator for &'a SmallSet<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a SmallSet<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for SmallSet<T, N>where
SetRepr<T, N>: Freeze,
impl<T, const N: usize> RefUnwindSafe for SmallSet<T, N>where
SetRepr<T, N>: RefUnwindSafe,
impl<T, const N: usize> Send for SmallSet<T, N>where
SetRepr<T, N>: Send,
impl<T, const N: usize> Sync for SmallSet<T, N>where
SetRepr<T, N>: Sync,
impl<T, const N: usize> Unpin for SmallSet<T, N>where
SetRepr<T, N>: Unpin,
impl<T, const N: usize> UnsafeUnpin for SmallSet<T, N>where
SetRepr<T, N>: UnsafeUnpin,
impl<T, const N: usize> UnwindSafe for SmallSet<T, N>where
SetRepr<T, N>: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more