Struct compact::CDict [−][src]
A simple linear-search key-value dictionary,
implemented using two CompactVec
's, one for keys, one for values.
The API loosely follows that of std::collections::HashMap
.
Spilling behaviour using Allocator
is equivalent to CompactVec
.
Methods
impl<K: Eq + Copy, V: Compact + Clone, A: Allocator> CompactDict<K, V, A>
[src]
impl<K: Eq + Copy, V: Compact + Clone, A: Allocator> CompactDict<K, V, A>
pub fn new() -> Self
[src]
pub fn new() -> Self
Create new, empty dictionary
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Amount of entries in the dictionary
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Is the dictionary empty?
pub fn get(&self, query: K) -> Option<&V>
[src]
pub fn get(&self, query: K) -> Option<&V>
Look up the value for key query
, if it exists
pub fn get_mut(&mut self, query: K) -> Option<&mut V>
[src]
pub fn get_mut(&mut self, query: K) -> Option<&mut V>
Look up the value for keu query
mutably, if it exists
pub fn get_mru(&mut self, query: K) -> Option<&V>
[src]
pub fn get_mru(&mut self, query: K) -> Option<&V>
Lookup up the value for key query
, if it exists, but also swap the entry
to the beginning of the key/value vectors, so a repeated lookup for that item will be faster
pub fn get_mfu(&mut self, query: K) -> Option<&V>
[src]
pub fn get_mfu(&mut self, query: K) -> Option<&V>
Lookup up the value for key query
, if it exists, but also swap the entry
one index towards the beginning of the key/value vectors, so frequently repeated lookups
for that item will be faster
pub fn contains_key(&self, query: K) -> bool
[src]
pub fn contains_key(&self, query: K) -> bool
Does the dictionary contain a value for query
?
pub fn insert(&mut self, query: K, new_value: V) -> Option<V>
[src]
pub fn insert(&mut self, query: K, new_value: V) -> Option<V>
Insert new value at key query
and return the previous value at that key, if any existed
pub fn remove(&mut self, query: K) -> Option<V>
[src]
pub fn remove(&mut self, query: K) -> Option<V>
Remove value at key query
and return it, if it existed
ⓘImportant traits for Iter<'a, T>pub fn keys(&self) -> Iter<K>
[src]
pub fn keys(&self) -> Iter<K>
Iterator over all keys in the dictionary
ⓘImportant traits for Iter<'a, T>pub fn values(&self) -> Iter<V>
[src]
pub fn values(&self) -> Iter<V>
Iterator over all values in the dictionary
ⓘImportant traits for IterMut<'a, T>pub fn values_mut(&mut self) -> IterMut<V>
[src]
pub fn values_mut(&mut self) -> IterMut<V>
Iterator over mutable references to all values in the dictionary
pub fn pairs<'a>(
&'a self
) -> impl Iterator<Item = (&'a K, &'a V)> + Clone + 'a
[src]
pub fn pairs<'a>(
&'a self
) -> impl Iterator<Item = (&'a K, &'a V)> + Clone + 'a
Iterator over all key-value pairs in the dictionary
impl<K: Eq + Copy, I: Compact, A1: Allocator, A2: Allocator> CompactDict<K, CompactVec<I, A1>, A2>
[src]
impl<K: Eq + Copy, I: Compact, A1: Allocator, A2: Allocator> CompactDict<K, CompactVec<I, A1>, A2>
pub fn push_at(&mut self, query: K, item: I)
[src]
pub fn push_at(&mut self, query: K, item: I)
Push a value onto the CompactVec
at the key query
pub fn get_iter<'a>(
&'a self,
query: K
) -> impl Iterator<Item = &'a I> + 'a
[src]
pub fn get_iter<'a>(
&'a self,
query: K
) -> impl Iterator<Item = &'a I> + 'a
Iterator over the CompactVec
at the key query
pub fn remove_iter<'a>(
&'a mut self,
query: K
) -> impl Iterator<Item = I> + 'a
[src]
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
impl<K: Copy, V: Compact + Clone, A: Allocator> Compact for CompactDict<K, V, A>
[src]
impl<K: Copy, V: Compact + Clone, A: Allocator> Compact for CompactDict<K, V, A>
fn is_still_compact(&self) -> bool
[src]
fn is_still_compact(&self) -> bool
Is the object's dynamic part stored compactly?
fn dynamic_size_bytes(&self) -> usize
[src]
fn dynamic_size_bytes(&self) -> usize
Size of the dynamic part in bytes
unsafe fn compact(source: *mut Self, dest: *mut Self, new_dynamic_part: *mut u8)
[src]
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. Read more
unsafe fn decompact(source: *const Self) -> CompactDict<K, V, A>
[src]
unsafe fn decompact(source: *const Self) -> CompactDict<K, V, A>
Creates a clone of self with the dynamic part guaranteed to be stored freely. Read more
fn total_size_bytes(&self) -> usize
[src]
fn total_size_bytes(&self) -> usize
Total size of the object (static part + dynamic part)
unsafe fn behind(ptr: *mut Self) -> *mut u8
[src]
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)
unsafe fn compact_behind(source: *mut Self, dest: *mut Self)
[src]
unsafe fn compact_behind(source: *mut Self, dest: *mut Self)
Like compact
with new_dynamic_part
set to dest.behind()
impl<K: Copy, V: Compact + Clone, A: Allocator> Clone for CompactDict<K, V, A>
[src]
impl<K: Copy, V: Compact + Clone, A: Allocator> Clone for CompactDict<K, V, A>
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Default for CompactDict<K, V, A>
[src]
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Default for CompactDict<K, V, A>
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> FromIterator<(K, V)> for CompactDict<K, V, A>
[src]
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> FromIterator<(K, V)> for CompactDict<K, V, A>
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
[src]
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
Construct a compact dictionary from an interator over key-value pairs
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Extend<(K, V)> for CompactDict<K, V, A>
[src]
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Extend<(K, V)> for CompactDict<K, V, A>
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Extend a compact dictionary from an iterator over key-value pairs