[−][src]Struct ccl::dhashmap::DHashMap
DHashMap is a threadsafe, versatile and concurrent hashmap with good performance and is balanced for both reads and writes.
The API mostly matches that of the standard library hashmap but there are some differences to due to the design.
One of those limits is iteration, you cannot iterate over the elements directly. Instead you have to iterate over chunks which can iterate over KV pairs.
Unsafe is used to avoid bounds checking when accessing chunks. This is guaranteed to be safe since we cannot possibly get a value higher than the amount of chunks. The amount of chunks cannot be altered after creation in any way.
Methods
impl<'a, K: 'a, V: 'a> DHashMap<K, V> where
K: Hash + Eq, [src]
K: Hash + Eq,
pub fn new(submaps_exp_of_two_pow: usize) -> Self[src]
Create a new DHashMap. The amount of chunks used is based on the formula 2^n where n is the value passed. The default method will automagically determine the optimal amount.
Will panic if the first parameter plugged into the formula 2^n produces a result higher than isize::MAX.
pub fn with_capacity(submaps_exp_of_two_pow: usize, capacity: usize) -> Self[src]
Create a new DHashMap with a specified capacity.
Will panic if the first parameter plugged into the formula 2^n produces a result higher than isize::MAX.
pub fn insert(&self, key: K, value: V)[src]
Insert an element into the map.
pub fn contains_key(&self, key: &K) -> bool[src]
Check if the map contains the specified key.
pub fn get(&'a self, key: &'a K) -> Option<DHashMapRef<'a, K, V>>[src]
Get a shared reference to an element contained within the map.
pub fn index(&'a self, key: &'a K) -> DHashMapRef<'a, K, V>[src]
Shortcut for a get followed by an unwrap.
pub fn get_mut(&'a self, key: &'a K) -> Option<DHashMapRefMut<'a, K, V>>[src]
Get a unique reference to an element contained within the map.
pub fn index_mut(&'a self, key: &'a K) -> DHashMapRefMut<'a, K, V>[src]
Shortcut for a get_mut followed by an unwrap.
pub fn remove(&self, key: &K) -> Option<(K, V)>[src]
Remove an element from the map if it exists. Will return the K, V pair.
pub fn retain<F: Clone + FnMut(&K, &mut V) -> bool>(&self, f: F)[src]
Retain all elements that the specified function returns true for.
pub fn clear(&self)[src]
Clear all elements from the map.
pub fn alter<F: FnMut((&K, &mut V)) + Clone>(&self, f: F)[src]
Apply a function to every item in the map.
pub fn tables_read(&self) -> impl Iterator<Item = SMRInterface<K, V>>[src]
Iterate over chunks in a read only fashion.
pub fn tables_write(&self) -> impl Iterator<Item = SMRWInterface<K, V>>[src]
Iterate over chunks in a read-write fashion.
Trait Implementations
Auto Trait Implementations
impl<K, V> Send for DHashMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for DHashMap<K, V> where
K: Send + Sync,
V: Send + Sync,
K: Send + Sync,
V: Send + Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,