[][src]Trait multiproof_rs::tree::Tree

pub trait Tree<N: NodeType>: Sized {
    fn is_leaf(&self) -> bool;
fn is_empty(&self) -> bool;
fn num_children(&self) -> usize;
fn ith_child(&self, index: usize) -> Option<&Self>;
fn set_ith_child(&mut self, index: usize, child: &Self);
fn insert(&mut self, key: &N::Key, value: N::Value) -> Result<(), String>;
fn has_key(&self, key: &N::Key) -> bool;
fn value(&self) -> Option<&N::Value>;
fn value_length(&self) -> Option<usize>;
fn from_hash(h: Vec<u8>) -> Self;
fn new_empty() -> Self;
fn new_extension(ext: Vec<u8>, child: Self) -> Self;
fn new_branch() -> Self;
fn new_leaf(key: Vec<u8>, value: Vec<u8>) -> Self; fn children(&self) -> NodeChildIterator<N, Self> { ... } }

A trait representing the an underlying tree structure.

Required methods

fn is_leaf(&self) -> bool

Specifies if the current tree is a simple leaf.

fn is_empty(&self) -> bool

Specifies if the current tree is empty.

fn num_children(&self) -> usize

Returns the tree root's maximal number of children.

fn ith_child(&self, index: usize) -> Option<&Self>

Returns a pointer to child #i, or None if no such child exists.

fn set_ith_child(&mut self, index: usize, child: &Self)

Set child node #i of the current node.

fn insert(&mut self, key: &N::Key, value: N::Value) -> Result<(), String>

Insert a (key,value) pair into a (sub-)tree represented by root.

fn has_key(&self, key: &N::Key) -> bool

Returns true if the current tree contains key as a key.

fn value(&self) -> Option<&N::Value>

fn value_length(&self) -> Option<usize>

fn from_hash(h: Vec<u8>) -> Self

fn new_empty() -> Self

fn new_extension(ext: Vec<u8>, child: Self) -> Self

fn new_branch() -> Self

fn new_leaf(key: Vec<u8>, value: Vec<u8>) -> Self

Loading content...

Provided methods

Important traits for NodeChildIterator<'a, N, T>
fn children(&self) -> NodeChildIterator<N, Self>

Returns an iterator to the node's children. Some of these nodes can be empty.

Loading content...

Implementors

impl Tree<BinaryTree> for BinaryTree[src]

impl Tree<Node> for Node[src]

fn num_children(&self) -> usize[src]

Returns the maximum child count of the tree's root.

Branch nodes will always report 16, as empty slots are counted as children.

fn ith_child(&self, index: usize) -> Option<&Self>[src]

Return the tree root's ith child.

The function will return EmptySlot instead of None if a branch node has no ith child.

Loading content...