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> PartialOrd for RbTree<K, V>
impl<K, V> PartialOrd for RbTree<K, V>
impl<K, V> Eq for RbTree<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for RbTree<K, V>
impl<K, V> RefUnwindSafe for RbTree<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for RbTree<K, V>
impl<K, V> Sync for RbTree<K, V>
impl<K, V> Unpin for RbTree<K, V>
impl<K, V> UnwindSafe for RbTree<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)