pub struct Set<K, const B: usize = 32, const S: usize = 8, ST = u8, H = WyHash>{ /* private fields */ }Expand description
An efficient, immutable set.
Implementations§
Source§impl<K, const B: usize, const S: usize, ST, H> Set<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Set<K, B, S, ST, H>
Sourcepub fn from_iter_with_params<I>(iter: I, gamma: f32) -> Result<Self, MphfError>where
I: IntoIterator<Item = K>,
pub fn from_iter_with_params<I>(iter: I, gamma: f32) -> Result<Self, MphfError>where
I: IntoIterator<Item = K>,
Constructs a Set from an iterator of keys and MPHF function parameters.
§Examples
use entropy_map::{Set, DEFAULT_GAMMA};
let set: Set<u32> = Set::from_iter_with_params([1, 2, 3], DEFAULT_GAMMA).unwrap();
assert!(set.contains(&1));Sourcepub fn contains<Q>(&self, key: &Q) -> bool
pub fn contains<Q>(&self, key: &Q) -> bool
Returns true if the set contains the value.
§Examples
let set = Set::try_from(HashSet::from([1, 2, 3])).unwrap();
assert_eq!(set.contains(&1), true);
assert_eq!(set.contains(&4), false);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the set.
§Examples
let set = Set::try_from(HashSet::from([1, 2, 3])).unwrap();
assert_eq!(set.len(), 3);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the set contains no elements.
§Examples
let set = Set::try_from(HashSet::from([0u32; 0])).unwrap();
assert_eq!(set.is_empty(), true);
let set = Set::try_from(HashSet::from([1, 2, 3])).unwrap();
assert_eq!(set.is_empty(), false);Trait Implementations§
Auto Trait Implementations§
impl<K, const B: usize, const S: usize, ST, H> Freeze for Set<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> RefUnwindSafe for Set<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Send for Set<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Sync for Set<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Unpin for Set<K, B, S, ST, H>where
H: Unpin,
impl<K, const B: usize, const S: usize, ST, H> UnwindSafe for Set<K, B, S, ST, H>
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
Mutably borrows from an owned value. Read more