pub struct AvlTree<K: Ord + AsBytes, V> {
pub root: Option<Box<AvlNode<K, V>>>,
}Expand description
An AVL Tree that supports get and insert operation and can be used to prove existence of a
given key-value couple.
Fields§
§root: Option<Box<AvlNode<K, V>>>Implementations§
Source§impl<K: Ord + AsBytes, V: Borrow<[u8]>> AvlTree<K, V>
impl<K: Ord + AsBytes, V: Borrow<[u8]>> AvlTree<K, V>
Sourcepub fn root_hash(&self) -> Option<&Hash>
pub fn root_hash(&self) -> Option<&Hash>
Return the hash of the merkle tree root, if it has at least one node.
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get<Q>(&self, key: &Q) -> Option<&V>
Return the value corresponding to the key, if it exists.
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Insert a value into the AVL tree, this operation runs in amortized O(log(n)).
Sourcepub fn remove(&mut self, key: K) -> Option<V>
pub fn remove(&mut self, key: K) -> Option<V>
Remove a value from the AVL tree, this operation runs in amortized O(log(n)).
Sourcepub fn get_proof<Q>(&self, key: &Q) -> CommitmentProof
pub fn get_proof<Q>(&self, key: &Q) -> CommitmentProof
Return an existence proof for the given element, if it exists. Otherwise return a non-existence proof.
Sourcepub fn rotate_right(root: &mut Option<Box<AvlNode<K, V>>>)
pub fn rotate_right(root: &mut Option<Box<AvlNode<K, V>>>)
Performs a right rotation.
Sourcepub fn rotate_left(root: &mut Option<Box<AvlNode<K, V>>>)
pub fn rotate_left(root: &mut Option<Box<AvlNode<K, V>>>)
Perform a left rotation.
Trait Implementations§
impl<K: Eq + Ord + AsBytes, V: Eq> Eq for AvlTree<K, V>
impl<K: Ord + AsBytes, V> StructuralPartialEq for AvlTree<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for AvlTree<K, V>
impl<K, V> RefUnwindSafe for AvlTree<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for AvlTree<K, V>
impl<K, V> Sync for AvlTree<K, V>
impl<K, V> Unpin for AvlTree<K, V>
impl<K, V> UnwindSafe for AvlTree<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
Mutably borrows from an owned value. Read more