Struct everscale_types::RawDict
source · pub struct RawDict<C: CellFamily, const N: u16>(_);Expand description
Dictionary with fixed length keys (where N is a number of bits in each key).
TLB scheme
// ordinary Hashmap / HashmapE, with fixed length keys
hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n)
{n = (~m) + l} node:(HashmapNode m X) = Hashmap n X;
hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X;
hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X)
right:^(Hashmap n X) = HashmapNode (n + 1) X;
hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m;
hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m;
hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m;
hme_empty$0 {n:#} {X:Type} = HashmapE n X;
hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X;
unary_zero$0 = Unary ~0;
unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1);
bit$_ (## 1) = Bit;
Implementations§
source§impl<C: CellFamily, const N: u16> RawDict<C, N>
impl<C: CellFamily, const N: u16> RawDict<C, N>
source§impl<C, const N: u16> RawDict<C, N>where
for<'c> C: CellFamily + 'c,
impl<C, const N: u16> RawDict<C, N>where for<'c> C: CellFamily + 'c,
sourcepub fn load_from_root_ext(
slice: &mut CellSlice<'_, C>,
finalizer: &mut dyn Finalizer<C>
) -> Option<Self>
pub fn load_from_root_ext( slice: &mut CellSlice<'_, C>, finalizer: &mut dyn Finalizer<C> ) -> Option<Self>
Loads a non-empty dictionary from a root cell.
source§impl<C, const N: u16> RawDict<C, N>where
for<'c> C: CellFamily + 'c,
impl<C, const N: u16> RawDict<C, N>where for<'c> C: CellFamily + 'c,
sourcepub fn get<'a: 'b, 'b>(
&'a self,
key: CellSlice<'b, C>
) -> Result<Option<CellSlice<'a, C>>, Error>
pub fn get<'a: 'b, 'b>( &'a self, key: CellSlice<'b, C> ) -> Result<Option<CellSlice<'a, C>>, Error>
Returns a CellSlice of the value corresponding to the key.
sourcepub fn contains_key(&self, key: CellSlice<'_, C>) -> Result<bool, Error>
pub fn contains_key(&self, key: CellSlice<'_, C>) -> Result<bool, Error>
Returns true if the dictionary contains a value for the specified key.
sourcepub fn set_ext(
&mut self,
key: CellSlice<'_, C>,
value: CellSlice<'_, C>,
finalizer: &mut dyn Finalizer<C>
) -> Result<(), Error>
pub fn set_ext( &mut self, key: CellSlice<'_, C>, value: CellSlice<'_, C>, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>
Sets the value associated with the key in the dictionary.
sourcepub fn replace_ext(
&mut self,
key: CellSlice<'_, C>,
value: CellSlice<'_, C>,
finalizer: &mut dyn Finalizer<C>
) -> Result<(), Error>
pub fn replace_ext( &mut self, key: CellSlice<'_, C>, value: CellSlice<'_, C>, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>
Sets the value associated with the key in the dictionary only if the key was already present in it.
sourcepub fn add_ext(
&mut self,
key: CellSlice<'_, C>,
value: CellSlice<'_, C>,
finalizer: &mut dyn Finalizer<C>
) -> Result<(), Error>
pub fn add_ext( &mut self, key: CellSlice<'_, C>, value: CellSlice<'_, C>, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>
Sets the value associated with key in dictionary, but only if it is not already present.
sourcepub fn iter(&self) -> RawIter<'_, C> ⓘ
pub fn iter(&self) -> RawIter<'_, C> ⓘ
Gets an iterator over the entries of the dictionary, sorted by key.
The iterator element type is Result<(CellBuilder<C>, CellSlice<C>)>.
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.
sourcepub fn keys(&self) -> RawKeys<'_, C> ⓘ
pub fn keys(&self) -> RawKeys<'_, C> ⓘ
Gets an iterator over the keys of the dictionary, in sorted order.
The iterator element type is Result<CellBuilder<C>>.
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<C, const N: u16> RawDict<C, N>where
for<'c> C: DefaultFinalizer + 'c,
impl<C, const N: u16> RawDict<C, N>where for<'c> C: DefaultFinalizer + 'c,
sourcepub fn set(
&mut self,
key: CellSlice<'_, C>,
value: CellSlice<'_, C>
) -> Result<(), Error>
pub fn set( &mut self, key: CellSlice<'_, C>, value: CellSlice<'_, C> ) -> Result<(), Error>
Sets the value associated with the key in the dictionary.
Use set_ext if you need to use a custom finalizer.