Struct ic_certified_map::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
sourceimpl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> RbTree<K, V>
impl<K: 'static + AsRef<[u8]>, V: AsHashTree + 'static> RbTree<K, V>
pub fn get(&self, key: &[u8]) -> Option<&V>
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<'a>(&'a self, key: &[u8]) -> HashTree<'a>
pub fn witness<'a>(&'a self, key: &[u8]) -> HashTree<'a>
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<'a>
) -> HashTree<'a>
pub fn nested_witness<'a>(
&'a self,
key: &[u8],
f: impl FnOnce(&'a V) -> HashTree<'a>
) -> HashTree<'a>
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.
pub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'a, K, V>impl<'a, K, V> Iterator for Iter<'a, K, V> type Item = (&'a K, &'a V);
Trait Implementations
sourceimpl<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>
sourceimpl<K, V> Debug for RbTree<K, V>where
K: 'static + AsRef<[u8]> + Debug,
V: 'static + AsHashTree + Debug,
impl<K, V> Debug for RbTree<K, V>where
K: 'static + AsRef<[u8]> + Debug,
V: 'static + AsHashTree + Debug,
sourceimpl<K, V> FromIterator<(K, V)> for RbTree<K, V>where
K: 'static + AsRef<[u8]>,
V: 'static + AsHashTree,
impl<K, V> FromIterator<(K, V)> for RbTree<K, V>where
K: 'static + AsRef<[u8]>,
V: 'static + AsHashTree,
sourcefn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = (K, V)>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = (K, V)>,
sourceimpl<K, V> Ord for RbTree<K, V>where
K: 'static + AsRef<[u8]> + Ord,
V: 'static + AsHashTree + Ord,
impl<K, V> Ord for RbTree<K, V>where
K: 'static + AsRef<[u8]> + Ord,
V: 'static + AsHashTree + Ord,
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<K, V> PartialEq<RbTree<K, V>> for RbTree<K, V>where
K: 'static + AsRef<[u8]> + PartialEq,
V: 'static + AsHashTree + PartialEq,
impl<K, V> PartialEq<RbTree<K, V>> for RbTree<K, V>where
K: 'static + AsRef<[u8]> + PartialEq,
V: 'static + AsHashTree + PartialEq,
sourceimpl<K, V> PartialOrd<RbTree<K, V>> for RbTree<K, V>where
K: 'static + AsRef<[u8]> + PartialOrd,
V: 'static + AsHashTree + PartialOrd,
impl<K, V> PartialOrd<RbTree<K, V>> for RbTree<K, V>where
K: 'static + AsRef<[u8]> + PartialOrd,
V: 'static + AsHashTree + PartialOrd,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more