pub struct MapWithDictBitpacked<K, const B: usize = 32, const S: usize = 8, ST = u8, H = WyHash>{ /* private fields */ }Expand description
An efficient, immutable hash map with bit-packed Vec<u32> values for optimized space usage.
Implementations§
Source§impl<K, const B: usize, const S: usize, ST, H> MapWithDictBitpacked<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> MapWithDictBitpacked<K, B, S, ST, H>
Sourcepub fn from_iter_with_params<I>(iter: I, gamma: f32) -> Result<Self, Error>
pub fn from_iter_with_params<I>(iter: I, gamma: f32) -> Result<Self, Error>
Constructs a MapWithDictBitpacked from an iterator of key-value pairs and MPHF function params.
Sourcepub fn get_values<Q>(&self, key: &Q, values: &mut [u32]) -> bool
pub fn get_values<Q>(&self, key: &Q, values: &mut [u32]) -> bool
Updates values to the array of values corresponding to the key. Returns false if the
key is not not present in the map.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
let mut values = [0];
assert_eq!(map.get_values(&1, &mut values), true);
assert_eq!(values, [2]);
assert_eq!(map.get_values(&2, &mut values), false);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of keys in the map.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
assert_eq!(map.len(), 2);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the map contains no elements.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(0, vec![0]); 0])).unwrap();
assert_eq!(map.is_empty(), true);
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
assert_eq!(map.is_empty(), false);Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Checks if the map contains the specified key.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);Sourcepub fn iter(&self, n: usize) -> impl Iterator<Item = (&K, Vec<u32>)>
pub fn iter(&self, n: usize) -> impl Iterator<Item = (&K, Vec<u32>)>
Returns an iterator over the map, yielding key-value pairs.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
for (key, val) in map.iter(1) {
println!("key: {key} val: {val:?}");
}Sourcepub fn keys(&self) -> impl Iterator<Item = &K>
pub fn keys(&self) -> impl Iterator<Item = &K>
Returns an iterator over the keys of the map.
§Examples
let map = MapWithDictBitpacked::try_from(HashMap::from([(1, vec![2]), (3, vec![4])])).unwrap();
for key in map.keys() {
println!("{key}");
}Trait Implementations§
Source§impl<K: Default, const B: usize, const S: usize, ST, H> Default for MapWithDictBitpacked<K, B, S, ST, H>
impl<K: Default, const B: usize, const S: usize, ST, H> Default for MapWithDictBitpacked<K, B, S, ST, H>
Source§fn default() -> MapWithDictBitpacked<K, B, S, ST, H>
fn default() -> MapWithDictBitpacked<K, B, S, ST, H>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<K, const B: usize, const S: usize, ST, H> Freeze for MapWithDictBitpacked<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> RefUnwindSafe for MapWithDictBitpacked<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Send for MapWithDictBitpacked<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Sync for MapWithDictBitpacked<K, B, S, ST, H>
impl<K, const B: usize, const S: usize, ST, H> Unpin for MapWithDictBitpacked<K, B, S, ST, H>where
H: Unpin,
impl<K, const B: usize, const S: usize, ST, H> UnwindSafe for MapWithDictBitpacked<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