pub struct FzHashSet<T, BH = RandomState> { /* private fields */ }Expand description
A set optimized for fast read access with hashable values.
A frozen collection differs from the traditional Rust collections, such as
HashMap and 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.
§Alternate Choices
If your values are integers or enum variants, you should use the FzScalarSet type instead.
If your values are strings, you should use the FzStringSet type instead. Both of these will
deliver better performance since they are specifically optimized for those value types.
If your values are known at compile time, consider using the various fz_*_set macros instead of
this type as they generally perform better.
Implementations§
Source§impl<T, BH> FzHashSet<T, BH>where
BH: BuildHasher,
impl<T, BH> FzHashSet<T, BH>where
BH: BuildHasher,
Sourcepub fn with_hasher(entries: Vec<T>, bh: BH) -> FzHashSet<T, BH>
pub fn with_hasher(entries: Vec<T>, bh: BH) -> FzHashSet<T, BH>
Creates a new frozen set which uses the given hash builder to hash values. If the input contains duplicate value, the latter one in the input is used and all former ones are discarded.
Trait Implementations§
Source§impl<'de, T, BH> Deserialize<'de> for FzHashSet<T, BH>
Available on crate feature serde only.
impl<'de, T, BH> Deserialize<'de> for FzHashSet<T, BH>
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<FzHashSet<T, BH>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FzHashSet<T, BH>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<T, BH> FromIterator<T> for FzHashSet<T, BH>
impl<T, BH> FromIterator<T> for FzHashSet<T, BH>
Source§impl<'a, T, BH> IntoIterator for &'a FzHashSet<T, BH>where
BH: BuildHasher,
impl<'a, T, BH> IntoIterator for &'a FzHashSet<T, BH>where
BH: BuildHasher,
Source§impl<T, BH> IntoIterator for FzHashSet<T, BH>where
BH: BuildHasher,
impl<T, BH> IntoIterator for FzHashSet<T, BH>where
BH: BuildHasher,
Source§impl<T, BH> Len for FzHashSet<T, BH>where
BH: BuildHasher,
impl<T, BH> Len for FzHashSet<T, BH>where
BH: BuildHasher,
Source§impl<T, BH> Serialize for FzHashSet<T, BH>where
T: Serialize,
BH: BuildHasher,
Available on crate feature serde only.
impl<T, BH> Serialize for FzHashSet<T, BH>where
T: Serialize,
BH: BuildHasher,
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<T, BH> SetIteration<T> for FzHashSet<T, BH>where
BH: BuildHasher,
impl<T, BH> SetIteration<T> for FzHashSet<T, BH>where
BH: BuildHasher,
impl<T, BH> Eq for FzHashSet<T, BH>
impl<T, Q, BH> Set<T, Q> for FzHashSet<T, BH>
Auto Trait Implementations§
impl<T, BH> Freeze for FzHashSet<T, BH>where
BH: Freeze,
impl<T, BH> RefUnwindSafe for FzHashSet<T, BH>where
BH: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, BH> Send for FzHashSet<T, BH>
impl<T, BH> Sync for FzHashSet<T, BH>
impl<T, BH> Unpin for FzHashSet<T, BH>where
BH: Unpin,
impl<T, BH> UnsafeUnpin for FzHashSet<T, BH>where
BH: UnsafeUnpin,
impl<T, BH> UnwindSafe for FzHashSet<T, BH>where
BH: UnwindSafe,
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<ST, T> SetOps<T> for STwhere
ST: Set<T>,
impl<ST, T> SetOps<T> for STwhere
ST: Set<T>,
Source§fn union<'a, ST>(&'a self, other: &'a ST) -> Union<'a, Self, ST, T> ⓘ
fn union<'a, ST>(&'a self, other: &'a ST) -> Union<'a, Self, ST, T> ⓘ
self or other, without duplicates.Source§fn symmetric_difference<'a, ST>(
&'a self,
other: &'a ST,
) -> SymmetricDifference<'a, Self, ST, T> ⓘ
fn symmetric_difference<'a, ST>( &'a self, other: &'a ST, ) -> SymmetricDifference<'a, Self, ST, T> ⓘ
self or in other but not in both.Source§fn difference<'a, ST>(&'a self, other: &'a ST) -> Difference<'a, Self, ST, T> ⓘ
fn difference<'a, ST>(&'a self, other: &'a ST) -> Difference<'a, Self, ST, T> ⓘ
self but not in other.Source§fn intersection<'a, ST>(
&'a self,
other: &'a ST,
) -> Intersection<'a, Self, ST, T> ⓘ
fn intersection<'a, ST>( &'a self, other: &'a ST, ) -> Intersection<'a, Self, ST, T> ⓘ
self and other. Read moreSource§fn is_disjoint<'a, ST>(&'a self, other: &'a ST) -> bool
fn is_disjoint<'a, ST>(&'a self, other: &'a ST) -> bool
true if self has no entries in common with other.
This is equivalent to checking for an empty intersection.