Struct ic_certification::rb_tree::RbTree
source · pub struct RbTree<K, V> { /* private fields */ }
Expand description
Implements mutable left-leaning red-black trees as defined in https://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
Implementations§
source§impl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> RbTree<K, V>
impl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> RbTree<K, V>
sourcepub fn get(&self, key: &[u8]) -> Option<&V>
pub fn get(&self, key: &[u8]) -> Option<&V>
Looks up the key in the map and returns the associated value, if there is one.
sourcepub fn modify(&mut self, key: &[u8], f: impl FnOnce(&mut V))
pub fn modify(&mut self, key: &[u8], f: impl FnOnce(&mut V))
Updates the value corresponding to the specified key.
sourcepub fn witness(&self, key: &[u8]) -> HashTree
pub fn witness(&self, key: &[u8]) -> HashTree
Constructs a hash tree that acts as a proof that there is a entry with the specified key in this map. The proof also contains the value in question.
If the key is not in the map, returns a proof of absence.
sourcepub fn nested_witness<'a>(
&'a self,
key: &[u8],
f: impl FnOnce(&'a V) -> HashTree
) -> HashTree
pub fn nested_witness<'a>( &'a self, key: &[u8], f: impl FnOnce(&'a V) -> HashTree ) -> HashTree
Like witness
, but gives the caller more control over the
construction of the value witness. This method is useful for
constructing witnesses for nested certified maps.
sourcepub fn keys(&self) -> HashTree
pub fn keys(&self) -> HashTree
Returns a witness enumerating all the keys in this map. The resulting tree doesn’t include values, they are replaced with “Pruned” nodes.
sourcepub fn key_range(&self, first: &[u8], last: &[u8]) -> HashTree
pub fn key_range(&self, first: &[u8], last: &[u8]) -> HashTree
Returns a witness for the keys in the specified range. The resulting tree doesn’t include values, they are replaced with “Pruned” nodes.
sourcepub fn value_range(&self, first: &[u8], last: &[u8]) -> HashTree
pub fn value_range(&self, first: &[u8], last: &[u8]) -> HashTree
Returns a witness for the key-value pairs in the specified range. The resulting tree contains both keys and values.
sourcepub fn keys_with_prefix(&self, prefix: &[u8]) -> HashTree
pub fn keys_with_prefix(&self, prefix: &[u8]) -> HashTree
Returns a witness that enumerates all the keys starting with the specified prefix.
Trait Implementations§
source§impl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> AsHashTree for RbTree<K, V>
impl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> AsHashTree for RbTree<K, V>
source§impl<K, V> FromIterator<(K, V)> for RbTree<K, V>
impl<K, V> FromIterator<(K, V)> for RbTree<K, V>
source§impl<K, V> Ord for RbTree<K, V>
impl<K, V> Ord for RbTree<K, V>
source§impl<K, V> PartialEq for RbTree<K, V>
impl<K, V> PartialEq for RbTree<K, V>
source§impl<K, V> PartialOrd for RbTree<K, V>
impl<K, V> PartialOrd for RbTree<K, V>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more