Skip to main content

InlineHashSet

Struct InlineHashSet 

Source
pub struct InlineHashSet<T, const SZ: usize, const NHS: usize, CM = SmallCollection, H = BridgeHasher> { /* private fields */ }
Expand description

A general-purpose set implemented using a hash table.

This type is an implementation detail of the `frozen_collections` crate. This API is therefore not stable and may change at any time. Please do not use this type directly, and instead use the public API provided by the `frozen_collections` crate.
A frozen collection differs from the traditional Rust collections, such as [`HashMap`](std::collections::HashMap) and [`HashSet`](std::collections::HashSet) types in three key ways. First, creating a frozen collection performs an analysis over the input data to determine the best implementation strategy. Depending on the situation, this analysis is performed at build time or runtime, and it can take a relatively long time when a collection is very large. Second, once created, the keys in frozen collections are immutable. And third, querying a frozen collection is typically considerably faster, which is the whole point.

This type requires that the keys implement the Eq and Hash traits. This can frequently be achieved by using #[derive(PartialEq, Eq, Hash)]. If you implement these yourself, it is important that the following property holds:

k1 == k2 -> hash(k1) == hash(k2)

In other words, if two keys are equal, their hashes must be equal. Violating this property is a logic error.

It is also a logic error for a key to be modified in such a way that the key’s hash, as determined by the Hash trait, or its equality, as determined by the Eq trait, changes while it is in the collection. This is normally only possible through core::cell::Cell, core::cell::RefCell, global state, I/O, or unsafe code.

The behavior resulting from either logic error can include panics, incorrect results, memory leaks, and non-termination.

§Type Parameters

Implementations§

Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> InlineHashSet<T, SZ, NHS, CM, H>

Source

pub const fn new(map: InlineHashMap<T, (), SZ, NHS, CM, H>) -> Self

Creates a frozen set.

Source

pub fn get<Q>(&self, value: &Q) -> Option<&T>
where Q: ?Sized + Equivalent<T>, H: Hasher<Q>,

Gets a reference to a value in the set.

Source

pub fn contains<Q>(&self, value: &Q) -> bool
where Q: ?Sized + Equivalent<T>, H: Hasher<Q>,

Checks whether a particular value is present in the set.

Source

pub fn iter(&self) -> Iter<'_, T>

An iterator visiting all entries in arbitrary order.

Source

pub const fn len(&self) -> usize

Returns the number of elements in the collection.

Source

pub const fn is_empty(&self) -> bool

Returns true if the collection contains no elements.

Trait Implementations§

Source§

impl<T, ST, const SZ: usize, const NHS: usize, CM, H> BitAnd<&ST> for &InlineHashSet<T, SZ, NHS, CM, H>
where T: Hash + Eq + Clone, ST: Set<T>, CM: CollectionMagnitude, H: Hasher<T>,

Source§

type Output = HashSet<T>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &ST) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, ST, const SZ: usize, const NHS: usize, CM, H> BitOr<&ST> for &InlineHashSet<T, SZ, NHS, CM, H>
where T: Hash + Eq + Clone, ST: Set<T>, CM: CollectionMagnitude, H: Hasher<T>,

Source§

type Output = HashSet<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &ST) -> Self::Output

Performs the | operation. Read more
Source§

impl<T, ST, const SZ: usize, const NHS: usize, CM, H> BitXor<&ST> for &InlineHashSet<T, SZ, NHS, CM, H>
where T: Hash + Eq + Clone, ST: Set<T>, CM: CollectionMagnitude, H: Hasher<T>,

Source§

type Output = HashSet<T>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &ST) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T: Clone, const SZ: usize, const NHS: usize, CM: Clone, H: Clone> Clone for InlineHashSet<T, SZ, NHS, CM, H>

Source§

fn clone(&self) -> InlineHashSet<T, SZ, NHS, CM, H>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> Debug for InlineHashSet<T, SZ, NHS, CM, H>
where T: Debug, CM: CollectionMagnitude, H: Hasher<T>,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, T, const SZ: usize, const NHS: usize, CM, H> IntoIterator for &'a InlineHashSet<T, SZ, NHS, CM, H>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> IntoIterator for InlineHashSet<T, SZ, NHS, CM, H>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> Len for InlineHashSet<T, SZ, NHS, CM, H>

Source§

fn len(&self) -> usize

Returns the number of elements in the collection.
Source§

fn is_empty(&self) -> bool

Returns true if the collection contains no elements.
Source§

impl<T, ST, const SZ: usize, const NHS: usize, CM, H> PartialEq<ST> for InlineHashSet<T, SZ, NHS, CM, H>
where T: PartialEq, ST: SetQuery<T>, CM: CollectionMagnitude, H: Hasher<T>,

Source§

fn eq(&self, other: &ST) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> Serialize for InlineHashSet<T, SZ, NHS, CM, H>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T, Q, const SZ: usize, const NHS: usize, CM, H> SetExtras<T, Q> for InlineHashSet<T, SZ, NHS, CM, H>
where Q: ?Sized + Equivalent<T>, CM: CollectionMagnitude, H: Hasher<Q>,

Source§

fn get(&self, value: &Q) -> Option<&T>

Gets a reference to a value in the set.
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> SetIteration<T> for InlineHashSet<T, SZ, NHS, CM, H>

Source§

type Iterator<'a> = Iter<'a, T> where T: 'a, CM: 'a, H: 'a

The type of the iterator returned by Self::iter.
Source§

fn iter(&self) -> Self::Iterator<'_>

An iterator visiting all entries in arbitrary order.
Source§

impl<T, Q, const SZ: usize, const NHS: usize, CM, H> SetQuery<Q> for InlineHashSet<T, SZ, NHS, CM, H>
where Q: ?Sized + Equivalent<T>, CM: CollectionMagnitude, H: Hasher<Q>,

Source§

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

Checks whether a particular value is present in the set.
Source§

impl<T, ST, const SZ: usize, const NHS: usize, CM, H> Sub<&ST> for &InlineHashSet<T, SZ, NHS, CM, H>
where T: Hash + Eq + Clone, ST: Set<T>, CM: CollectionMagnitude, H: Hasher<T>,

Source§

type Output = HashSet<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ST) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, const SZ: usize, const NHS: usize, CM, H> Eq for InlineHashSet<T, SZ, NHS, CM, H>
where T: Eq, CM: CollectionMagnitude, H: Hasher<T>,

Source§

impl<T, Q, const SZ: usize, const NHS: usize, CM, H> Set<T, Q> for InlineHashSet<T, SZ, NHS, CM, H>
where Q: ?Sized + Equivalent<T>, CM: CollectionMagnitude, H: Hasher<Q>,

Auto Trait Implementations§

§

impl<T, const SZ: usize, const NHS: usize, CM, H> Freeze for InlineHashSet<T, SZ, NHS, CM, H>
where H: Freeze, CM: Freeze, T: Freeze,

§

impl<T, const SZ: usize, const NHS: usize, CM, H> RefUnwindSafe for InlineHashSet<T, SZ, NHS, CM, H>

§

impl<T, const SZ: usize, const NHS: usize, CM, H> Send for InlineHashSet<T, SZ, NHS, CM, H>
where H: Send, CM: Send, T: Send,

§

impl<T, const SZ: usize, const NHS: usize, CM, H> Sync for InlineHashSet<T, SZ, NHS, CM, H>
where H: Sync, CM: Sync, T: Sync,

§

impl<T, const SZ: usize, const NHS: usize, CM, H> Unpin for InlineHashSet<T, SZ, NHS, CM, H>
where H: Unpin, CM: Unpin, T: Unpin,

§

impl<T, const SZ: usize, const NHS: usize, CM, H> UnsafeUnpin for InlineHashSet<T, SZ, NHS, CM, H>

§

impl<T, const SZ: usize, const NHS: usize, CM, H> UnwindSafe for InlineHashSet<T, SZ, NHS, CM, H>
where H: UnwindSafe, CM: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<ST, T> SetOps<T> for ST
where ST: Set<T>,

Source§

fn union<'a, ST>(&'a self, other: &'a ST) -> Union<'a, Self, ST, T>
where ST: Set<T>, Self: Sized + Set<T>,

Visits the values representing the union, i.e., all the values in self or other, without duplicates.
Source§

fn symmetric_difference<'a, ST>( &'a self, other: &'a ST, ) -> SymmetricDifference<'a, Self, ST, T>
where ST: Set<T>, Self: Sized + Set<T>,

Visits the values representing the symmetric difference, i.e., the values that are in self or in other but not in both.
Source§

fn difference<'a, ST>(&'a self, other: &'a ST) -> Difference<'a, Self, ST, T>
where ST: Set<T>, Self: Sized + Set<T>,

Visits the values representing the difference, i.e., the values that are in self but not in other.
Source§

fn intersection<'a, ST>( &'a self, other: &'a ST, ) -> Intersection<'a, Self, ST, T>
where ST: Set<T>, Self: Sized + Set<T>,

Visits the values representing the intersection, i.e., the values that are both in self and other. Read more
Source§

fn is_disjoint<'a, ST>(&'a self, other: &'a ST) -> bool
where ST: Set<T>, Self: Sized + Set<T>,

Returns true if self has no entries in common with other. This is equivalent to checking for an empty intersection.
Source§

fn is_subset<'a, ST>(&'a self, other: &'a ST) -> bool
where ST: Set<T>, Self: Sized + Set<T>,

Returns true if the set is a subset of another, i.e., other contains at least all the values in self.
Source§

fn is_superset<'a, ST>(&'a self, other: &'a ST) -> bool
where ST: Set<T>, Self: Sized + Set<T>,

Returns true if the set is a superset of another, i.e., self contains at least all the values in other.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.