SsoHashSet

Struct SsoHashSet 

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§

§

impl<T> SsoHashSet<T>

pub fn new() -> SsoHashSet<T>

Creates an empty SsoHashSet.

pub fn with_capacity(cap: usize) -> SsoHashSet<T>

Creates an empty SsoHashSet with the specified capacity.

pub fn clear(&mut self)

Clears the set, removing all values.

pub fn capacity(&self) -> usize

Returns the number of elements the set can hold without reallocating.

pub fn len(&self) -> usize

Returns the number of elements in the set.

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

pub fn iter(&self) -> impl Iterator<Item = &T>

An iterator visiting all elements in arbitrary order. The iterator element type is &'a T.

pub fn drain(&mut self) -> impl Iterator<Item = T>

Clears the set, returning all elements in an iterator.

§

impl<T> SsoHashSet<T>
where T: Eq + Hash,

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.

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.

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Retains only the elements specified by the predicate.

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.

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.

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.

pub fn remove(&mut self, value: &T) -> bool

Removes a value from the set. Returns whether the value was present in the set.

pub fn contains(&self, value: &T) -> bool

Returns true if the set contains a value.

Trait Implementations§

§

impl<T> Clone for SsoHashSet<T>
where T: Clone,

§

fn clone(&self) -> SsoHashSet<T>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for SsoHashSet<T>
where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Default for SsoHashSet<T>

§

fn default() -> SsoHashSet<T>

Returns the “default value” for a type. Read more
§

impl<'a, T> Extend<&'a T> for SsoHashSet<T>
where T: 'a + Eq + Hash + Copy,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a T>,

Extends a collection with the contents of an iterator. Read more
§

fn extend_one(&mut self, _: &'a T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<T> Extend<T> for SsoHashSet<T>
where T: Eq + Hash,

§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extends a collection with the contents of an iterator. Read more
§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl<T> FromIterator<T> for SsoHashSet<T>
where T: Eq + Hash,

§

fn from_iter<I>(iter: I) -> SsoHashSet<T>
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
§

impl<'a, T> IntoIterator for &'a SsoHashSet<T>

§

type IntoIter = Map<Either<Map<Iter<'a, (T, ())>, fn(&'a (T, ())) -> (&'a T, &'a ())>, Iter<'a, T, ()>>, fn((&'a T, &'a ())) -> &'a T>

Which kind of iterator are we turning this into?
§

type Item = &'a T

The type of the elements being iterated over.
§

fn into_iter( self, ) -> Map<Either<Map<Iter<'a, (T, ())>, fn(&'a (T, ())) -> (&'a T, &'a ())>, Iter<'a, T, ()>>, fn((&'a T, &'a ())) -> &'a T>

Creates an iterator from a value. Read more
§

impl<T> IntoIterator for SsoHashSet<T>

§

type IntoIter = Map<Either<IntoIter<(T, ()), 8>, IntoIter<T, ()>>, fn((T, ())) -> T>

Which kind of iterator are we turning this into?
§

type Item = T

The type of the elements being iterated over.
§

fn into_iter( self, ) -> Map<Either<IntoIter<(T, ()), 8>, IntoIter<T, ()>>, fn((T, ())) -> T>

Creates an iterator from a value. Read more

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§

§

impl<T> Aligned for T

§

const ALIGN: Alignment

Alignment of Self.
§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<T> DynClone for T
where T: Clone,

§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoEither for T

§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

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.