pub struct ArenaHashMap { /* private fields */ }Expand description
Customized HashMap with &[u8] keys
Its main particularity is that rather than storing its keys in the heap, keys are stored in a memory arena inline with the values.
The quirky API has the benefit of avoiding the computation of the hash of the key twice, or copying the key as long as there is no insert.
Implementations§
Source§impl ArenaHashMap
impl ArenaHashMap
pub fn new(table_size: usize) -> ArenaHashMap
pub fn read<Item: Copy + 'static>(&self, addr: Addr) -> Item
pub fn mem_usage(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn iter(&self) -> Iter<'_>
Sourcepub fn mutate_or_create<V, TMutator>(
&mut self,
key: &[u8],
updater: TMutator,
) -> UnorderedId
pub fn mutate_or_create<V, TMutator>( &mut self, key: &[u8], updater: TMutator, ) -> UnorderedId
update create a new entry for a given key if it does not exist
or updates the existing entry.
The actual logic for this update is define in the updater
argument.
If the key is not present, updater will receive None and
will be in charge of returning a default value.
If the key already as an associated value, then it will be passed
Some(previous_value).
Auto Trait Implementations§
impl Freeze for ArenaHashMap
impl RefUnwindSafe for ArenaHashMap
impl Send for ArenaHashMap
impl Sync for ArenaHashMap
impl Unpin for ArenaHashMap
impl UnwindSafe for ArenaHashMap
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