#[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: StoreImplementations§
Source§impl PerfectByteHashMap<Vec<u8>>
impl PerfectByteHashMap<Vec<u8>>
Sourcepub fn try_new(keys: &[u8]) -> Result<Self, ZeroTrieBuildError>
pub fn try_new(keys: &[u8]) -> Result<Self, ZeroTrieBuildError>
Computes a new PerfectByteHashMap.
(this is a doc-hidden API)
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 ==.