pub struct AugDict<K, A, V> { /* private fields */ }Expand description
Typed augmented dictionary with fixed length keys.
§TLB scheme
ahm_edge#_ {n:#} {V:Type} {A:Type} {l:#} {m:#}
label:(HmLabel ~l n) {n = (~m) + l}
node:(HashmapAugNode m V A) = HashmapAug n V A;
ahmn_leaf#_ {V:Type} {A:Type} extra:A value:V = HashmapAugNode 0 V A;
ahmn_fork#_ {n:#} {V:Type} {A:Type} left:^(HashmapAug n V A)
right:^(HashmapAug n V A) extra:A = HashmapAugNode (n + 1) V A;
ahme_empty$0 {n:#} {V:Type} {A:Type} extra:A = HashmapAugE n V A;
ahme_root$1 {n:#} {V:Type} {A:Type} root:^(HashmapAug n V A) extra:A = HashmapAugE n V A;Implementations§
Source§impl<K, A: Default, V> AugDict<K, A, V>
impl<K, A: Default, V> AugDict<K, A, V>
Sourcepub const fn from_parts(dict: Dict<K, (A, V)>, extra: A) -> Self
pub const fn from_parts(dict: Dict<K, (A, V)>, extra: A) -> Self
Manually constructs the dictionaty from parts.
Sourcepub fn into_parts(self) -> (Dict<K, (A, V)>, A)
pub fn into_parts(self) -> (Dict<K, (A, V)>, A)
Returns an underlying dictionary and the extra value.
Source§impl<K, A, V> AugDict<K, A, V>
impl<K, A, V> AugDict<K, A, V>
Sourcepub fn update_root_extra(&mut self) -> Result<(), Error>
pub fn update_root_extra(&mut self) -> Result<(), Error>
Recomputes the root extra value.
Source§impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
Source§impl<K, A, V> AugDict<K, A, V>
impl<K, A, V> AugDict<K, A, V>
Sourcepub fn try_from_btree<Q, E, T>(
sorted: &BTreeMap<Q, (E, T)>,
) -> Result<Self, Error>
pub fn try_from_btree<Q, E, T>( sorted: &BTreeMap<Q, (E, T)>, ) -> Result<Self, Error>
Builds a dictionary from a sorted collection.
Sourcepub fn try_from_sorted_slice<Q, E, T>(
sorted: &[(Q, E, T)],
) -> Result<Self, Error>
pub fn try_from_sorted_slice<Q, E, T>( sorted: &[(Q, E, T)], ) -> Result<Self, Error>
Builds a dictionary from a sorted slice.
Sourcepub fn set<Q, E, T>(&mut self, key: Q, aug: E, value: T) -> Result<bool, Error>
pub fn set<Q, E, T>(&mut self, key: Q, aug: E, value: T) -> Result<bool, Error>
Sets the augmented value associated with the key in the aug dictionary.
Use set_ext if you need to use a custom cell context.
Sourcepub fn set_ext<Q, E, T>(
&mut self,
key: Q,
aug: E,
value: T,
context: &mut dyn CellContext,
) -> Result<bool, Error>
pub fn set_ext<Q, E, T>( &mut self, key: Q, aug: E, value: T, context: &mut dyn CellContext, ) -> Result<bool, Error>
Sets the value associated with the key in the dictionary.
Sourcepub fn replace<Q, E, T>(
&mut self,
key: Q,
aug: E,
value: T,
) -> Result<bool, Error>
pub fn replace<Q, E, T>( &mut self, key: Q, aug: E, value: T, ) -> Result<bool, Error>
Sets the augmented value associated with the key in the aug dictionary only if the key was already present in it.
Use replace_ext if you need to use a custom cell context.
Sourcepub fn replace_ext<Q, E, T>(
&mut self,
key: Q,
aug: E,
value: T,
context: &mut dyn CellContext,
) -> Result<bool, Error>
pub fn replace_ext<Q, E, T>( &mut self, key: Q, aug: E, value: T, context: &mut dyn CellContext, ) -> Result<bool, Error>
Sets the value associated with the key in the dictionary only if the key was already present in it.
Sourcepub fn add<Q, E, T>(&mut self, key: Q, aug: E, value: T) -> Result<bool, Error>
pub fn add<Q, E, T>(&mut self, key: Q, aug: E, value: T) -> Result<bool, Error>
Sets the value associated with key in aug dictionary, but only if it is not already present.
Use add_ext if you need to use a custom cell context.
Sourcepub fn add_ext<Q, E, T>(
&mut self,
key: Q,
aug: E,
value: T,
context: &mut dyn CellContext,
) -> Result<bool, Error>
pub fn add_ext<Q, E, T>( &mut self, key: Q, aug: E, value: T, context: &mut dyn CellContext, ) -> Result<bool, Error>
Sets the value associated with key in dictionary, but only if it is not already present.
Sourcepub fn remove<Q>(&mut self, key: Q) -> Result<Option<(A, V)>, Error>
pub fn remove<Q>(&mut self, key: Q) -> Result<Option<(A, V)>, Error>
Removes the value associated with key in aug dictionary. Returns an optional removed value as cell slice parts.
Sourcepub fn remove_raw_ext<Q>(
&mut self,
key: Q,
context: &mut dyn CellContext,
) -> Result<Option<CellSliceParts>, Error>where
Q: Borrow<K>,
pub fn remove_raw_ext<Q>(
&mut self,
key: Q,
context: &mut dyn CellContext,
) -> Result<Option<CellSliceParts>, Error>where
Q: Borrow<K>,
Removes the value associated with key in dictionary. Returns an optional removed value as cell slice parts.
Sourcepub fn split(&self) -> Result<(Self, Self), Error>
pub fn split(&self) -> Result<(Self, Self), Error>
Split dictionary into 2 dictionaries by the first key bit.
Sourcepub fn split_ext(
&self,
context: &mut dyn CellContext,
) -> Result<(Self, Self), Error>
pub fn split_ext( &self, context: &mut dyn CellContext, ) -> Result<(Self, Self), Error>
Split dictionary into 2 dictionaries by the first key bit.
Sourcepub fn split_by_prefix(
&self,
key_prefix: &CellSlice<'_>,
) -> Result<(Self, Self), Error>
pub fn split_by_prefix( &self, key_prefix: &CellSlice<'_>, ) -> Result<(Self, Self), Error>
Split dictionary into 2 dictionaries at the prefix.
Sourcepub fn split_by_prefix_ext(
&self,
key_prefix: &CellSlice<'_>,
context: &mut dyn CellContext,
) -> Result<(Self, Self), Error>
pub fn split_by_prefix_ext( &self, key_prefix: &CellSlice<'_>, context: &mut dyn CellContext, ) -> Result<(Self, Self), Error>
Split dictionary into 2 dictionaries at the prefix.
Source§impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
Sourcepub fn iter<'a>(&'a self) -> AugIter<'a, K, A, V> ⓘwhere
V: Load<'a>,
pub fn iter<'a>(&'a self) -> AugIter<'a, K, A, V> ⓘwhere
V: Load<'a>,
Gets an iterator over the entries of the dictionary, sorted by key.
The iterator element type is Result<(K, A, V)>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
§Performance
In the current implementation, iterating over dictionary builds a key
for each element. Use values or raw_values if you don’t need keys from an iterator.
Sourcepub fn keys(&self) -> Keys<'_, K> ⓘ
pub fn keys(&self) -> Keys<'_, K> ⓘ
Gets an iterator over the keys of the dictionary, in sorted order.
The iterator element type is Result<K>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
§Performance
In the current implementation, iterating over dictionary builds a key
for each element. Use values if you don’t need keys from an iterator.
Source§impl<K, A, V> AugDict<K, A, V>
impl<K, A, V> AugDict<K, A, V>
Sourcepub fn raw_iter(&self) -> RawIter<'_> ⓘ
pub fn raw_iter(&self) -> RawIter<'_> ⓘ
Gets an iterator over the raw entries of the dictionary, sorted by key.
The iterator element type is Result<(CellBuilder, CellSlice)>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
§Performance
In the current implementation, iterating over dictionary builds a key
for each element. Use values or raw_values if you don’t need keys from an iterator.
Sourcepub fn raw_keys(&self) -> RawKeys<'_> ⓘ
pub fn raw_keys(&self) -> RawKeys<'_> ⓘ
Gets an iterator over the raw keys of the dictionary, in sorted order.
The iterator element type is Result<CellBuilder>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
§Performance
In the current implementation, iterating over dictionary builds a key
for each element. Use values or raw_values if you don’t need keys from an iterator.
Source§impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
impl<K, A, V> AugDict<K, A, V>where
K: DictKey,
Sourcepub fn raw_values(&self) -> RawValues<'_> ⓘ
pub fn raw_values(&self) -> RawValues<'_> ⓘ
Gets an iterator over the raw values of the dictionary, in order by key.
The iterator element type is Result<CellSlice>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
Trait Implementations§
Source§impl<K, A: ExactSize, V> ExactSize for AugDict<K, A, V>
impl<K, A: ExactSize, V> ExactSize for AugDict<K, A, V>
Source§fn exact_size(&self) -> Size
fn exact_size(&self) -> Size
Source§impl<K, A: Store, V> Store for AugDict<K, A, V>
impl<K, A: Store, V> Store for AugDict<K, A, V>
Source§fn store_into(
&self,
builder: &mut CellBuilder,
context: &mut dyn CellContext,
) -> Result<(), Error>
fn store_into( &self, builder: &mut CellBuilder, context: &mut dyn CellContext, ) -> Result<(), Error>
impl<K, A: Eq, V> Eq for AugDict<K, A, V>
Auto Trait Implementations§
impl<K, A, V> Freeze for AugDict<K, A, V>where
A: Freeze,
impl<K, A, V> !RefUnwindSafe for AugDict<K, A, V>
impl<K, A, V> Send for AugDict<K, A, V>
impl<K, A, V> Sync for AugDict<K, A, V>
impl<K, A, V> Unpin for AugDict<K, A, V>
impl<K, A, V> !UnwindSafe for AugDict<K, A, V>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self to key and returns true if they are equal.