Struct zerotrie::byte_phf::PerfectByteHashMap
source · #[repr(transparent)]pub struct PerfectByteHashMap<Store: ?Sized>(Store);
Expand description
A constant-time map from bytes to unique indices.
Uses a perfect hash function (see module-level documentation). Does not support mutation.
Standard layout: P, N bytes of Q, N bytes of expected keys
Tuple Fields§
§0: Store
Implementations§
source§impl PerfectByteHashMap<Vec<u8>>
impl PerfectByteHashMap<Vec<u8>>
source§impl<Store> PerfectByteHashMap<Store>
impl<Store> PerfectByteHashMap<Store>
sourcepub fn from_store(store: Store) -> Self
pub fn from_store(store: Store) -> Self
Creates an instance from a pre-existing store. See Self::as_bytes
.
source§impl<Store> PerfectByteHashMap<Store>
impl<Store> PerfectByteHashMap<Store>
sourcepub fn get(&self, key: u8) -> Option<usize>
pub fn get(&self, key: u8) -> Option<usize>
Gets the usize for the given byte, or None
if it is not in the map.
sourcepub fn num_items(&self) -> usize
pub fn num_items(&self) -> usize
This is called num_items
because len
is ambiguous: it could refer
to the number of items or the number of bytes.
sourcepub fn keys(&self) -> &[u8] ⓘ
pub fn keys(&self) -> &[u8] ⓘ
Get an iterator over the keys in the order in which they are stored in the map.
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the map as bytes. The map can be recovered with Self::from_store
or Self::from_bytes
.
source§impl PerfectByteHashMap<[u8]>
impl PerfectByteHashMap<[u8]>
sourcepub fn from_bytes(bytes: &[u8]) -> &Self
pub fn from_bytes(bytes: &[u8]) -> &Self
Creates an instance from pre-existing bytes. See Self::as_bytes
.
source§impl<Store> PerfectByteHashMap<Store>
impl<Store> PerfectByteHashMap<Store>
sourcepub fn as_borrowed(&self) -> &PerfectByteHashMap<[u8]>
pub fn as_borrowed(&self) -> &PerfectByteHashMap<[u8]>
Converts from PerfectByteHashMap<AsRef<[u8]>>
to &PerfectByteHashMap<[u8]>
Trait Implementations§
source§impl<Store: PartialEq + ?Sized> PartialEq for PerfectByteHashMap<Store>
impl<Store: PartialEq + ?Sized> PartialEq for PerfectByteHashMap<Store>
source§fn eq(&self, other: &PerfectByteHashMap<Store>) -> bool
fn eq(&self, other: &PerfectByteHashMap<Store>) -> bool
self
and other
values to be equal, and is used
by ==
.