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.