[−][src]Struct compact::CDict
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]
pub fn new() -> Self
[src]
Create new, empty dictionary
pub fn with_capacity(cap: usize) -> Self
[src]
Create new, empty dictionary with a given capactity
pub fn len(&self) -> usize
[src]
Amount of entries in the dictionary
pub fn is_empty(&self) -> bool
[src]
Is the dictionary empty?
pub fn get(&self, query: K) -> Option<&V>
[src]
Look up the value for key query
, if it exists
pub fn get_mut(&mut self, query: K) -> Option<&mut V>
[src]
Look up the value for keu query
mutably, if it exists
pub fn get_mru(&mut self, query: K) -> Option<&V>
[src]
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]
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]
Does the dictionary contain a value for query
?
pub fn insert(&mut self, query: K, new_value: V) -> Option<V>
[src]
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]
Remove value at key query
and return it, if it existed
pub fn keys(&self) -> Iter<K>
[src]
Iterator over all keys in the dictionary
pub fn values(&self) -> Iter<V>
[src]
Iterator over all values in the dictionary
pub fn values_mut(&mut self) -> IterMut<V>
[src]
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]
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]
pub fn push_at(&mut self, query: K, item: I)
[src]
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]
Iterator over the CompactVec
at the key query
pub fn remove_iter<'a>(&'a mut self, query: K) -> impl Iterator<Item = I> + 'a
[src]
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]
fn is_still_compact(&self) -> bool
[src]
fn dynamic_size_bytes(&self) -> usize
[src]
unsafe fn compact(source: *mut Self, dest: *mut Self, new_dynamic_part: *mut u8)
[src]
unsafe fn decompact(source: *const Self) -> CompactDict<K, V, A>
[src]
fn total_size_bytes(&self) -> usize
[src]
Total size of the object (static part + dynamic part)
unsafe fn behind(ptr: *mut Self) -> *mut u8
[src]
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]
Like compact
with new_dynamic_part
set to dest.behind()
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Extend<(K, V)> for CompactDict<K, V, A>
[src]
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
[src]
Extend a compact dictionary from an iterator over key-value pairs
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> Default for CompactDict<K, V, A>
[src]
impl<K: Copy, V: Compact + Clone, A: Allocator> Clone for CompactDict<K, V, A>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K, V, A> Debug for CompactDict<K, V, A> where
K: Copy + Eq + Debug,
V: Compact + Debug,
A: Allocator,
[src]
K: Copy + Eq + Debug,
V: Compact + Debug,
A: Allocator,
impl<K: Copy + Eq, V: Compact + Clone, A: Allocator> FromIterator<(K, V)> for CompactDict<K, V, A>
[src]
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
[src]
Construct a compact dictionary from an interator over key-value pairs
Auto Trait Implementations
impl<K, V, A = DefaultHeap> !Send for CompactDict<K, V, A>
impl<K, V, A> Unpin for CompactDict<K, V, A> where
A: Unpin,
K: Unpin,
V: Unpin,
A: Unpin,
K: Unpin,
V: Unpin,
impl<K, V, A = DefaultHeap> !Sync for CompactDict<K, V, A>
impl<K, V, A> UnwindSafe for CompactDict<K, V, A> where
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, A> RefUnwindSafe for CompactDict<K, V, A> where
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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,