CHashMap

Struct CHashMap 

Source
pub struct CHashMap<K, V, A: Allocator = DefaultHeap> { /* private fields */ }
Expand description

A dynamically-sized open adressing quadratic probing hashmap that can be stored in compact sequential storage and automatically spills over into free heap storage using Allocator.

Implementations§

Source§

impl<K: Copy + Eq + Hash, V: Compact, A: Allocator> OpenAddressingMap<K, V, A>

Source

pub fn new() -> Self

constructor

Source

pub fn with_capacity(l: usize) -> Self

constructor

Source

pub fn len(&self) -> usize

Amount of entries in the dictionary

Source

pub fn is_empty(&self) -> bool

Is the dictionary empty?

Source

pub fn get(&self, query: K) -> Option<&V>

Look up the value for key query, if it exists

Source

pub fn get_mut(&mut self, query: K) -> Option<&mut V>

get mutable

Source

pub fn contains_key(&self, query: K) -> bool

Does the dictionary contain a value for query?

Source

pub fn insert(&mut self, query: K, value: V) -> Option<V>

Insert new value at key query and return the previous value at that key, if any existed

Source

pub fn remove(&mut self, query: K) -> Option<V>

Remove value at key query and return it, if it existed

Source

pub fn keys<'a>(&'a self) -> impl Iterator<Item = &'a K> + 'a

Iterator over all keys in the dictionary

Source

pub fn values<'a>(&'a self) -> impl Iterator<Item = &'a V> + 'a

Iterator over all values in the dictionary

Source

pub fn values_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut V> + 'a

Iterator over mutable references to all values in the dictionary

Source

pub fn pairs<'a>(&'a self) -> impl Iterator<Item = (&'a K, &'a V)> + 'a

Iterator over all key-value pairs in the dictionary

Source

pub fn pairs_mut<'a>(&'a mut self) -> impl Iterator<Item = (K, &'a mut V)> + 'a
where K: Copy,

Iterator over all key-value pairs in the dictionary, with the value as a mutable reference

Source§

impl<K: Hash + Eq + Copy, I: Compact, A1: Allocator, A2: Allocator> OpenAddressingMap<K, CompactVec<I, A1>, A2>

Source

pub fn push_at(&mut self, query: K, item: I)

Push a value onto the CompactVec at the key query

Source

pub fn get_iter<'a>(&'a self, query: K) -> impl Iterator<Item = &'a I> + 'a

Iterator over the CompactVec at the key query

Source

pub fn remove_iter<'a>(&'a mut self, query: K) -> impl Iterator<Item = I> + 'a

Remove the CompactVec at the key query and iterate over its elements (if it existed)

Trait Implementations§

Source§

impl<K: Copy, V: Compact + Clone, A: Allocator> Clone for OpenAddressingMap<K, V, A>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Copy + Eq + Hash, V: Compact, A: Allocator> Compact for OpenAddressingMap<K, V, A>

Source§

default fn is_still_compact(&self) -> bool

Is the object’s dynamic part stored compactly?
Source§

default fn dynamic_size_bytes(&self) -> usize

Size of the dynamic part in bytes
Source§

default unsafe fn compact( source: *mut Self, dest: *mut Self, new_dynamic_part: *mut u8, )

Copy the static part of source to dest and compactly store the dynamic part of source as the new dynamic part of dest at new_dynamic_part. This semantically moves source into dest.
Source§

unsafe fn decompact(source: *const Self) -> OpenAddressingMap<K, V, A>

Creates a clone of self with the dynamic part guaranteed to be stored freely. Read more
Source§

fn total_size_bytes(&self) -> usize

Total size of the object (static part + dynamic part)
Source§

unsafe fn behind(ptr: *mut Self) -> *mut u8

Get a pointer to behind the static part of self (commonly used place for the dynamic part)
Source§

unsafe fn compact_behind(source: *mut Self, dest: *mut Self)

Like compact with new_dynamic_part set to dest.behind()
Source§

impl<K: Copy + Eq + Hash + Debug, V: Compact + Clone + Debug, A: Allocator> Debug for OpenAddressingMap<K, V, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Copy + Eq + Hash, V: Compact, A: Allocator> Default for OpenAddressingMap<K, V, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K: Copy + Eq + Hash, V: Compact + Clone, A: Allocator> FromIterator<(K, V)> for OpenAddressingMap<K, V, A>

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter_to_be: T) -> Self

Construct a compact dictionary from an interator over key-value pairs

Auto Trait Implementations§

§

impl<K, V, A> Freeze for OpenAddressingMap<K, V, A>

§

impl<K, V, A> RefUnwindSafe for OpenAddressingMap<K, V, A>

§

impl<K, V, A = DefaultHeap> !Send for OpenAddressingMap<K, V, A>

§

impl<K, V, A = DefaultHeap> !Sync for OpenAddressingMap<K, V, A>

§

impl<K, V, A> Unpin for OpenAddressingMap<K, V, A>

§

impl<K, V, A> UnwindSafe for OpenAddressingMap<K, V, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.