Struct ego_tree::Tree
[−]
[src]
pub struct Tree<T> { /* fields omitted */ }
A Vec-backed tree.
Nodes are allocated in a Vec
which is only ever pushed to. NodeId
is an opaque index into
the Vec
.
Each Tree
has a unique ID which is also given to each NodeId
it creates. This is used to
bounds check a NodeId
.
Methods
impl<T> Tree<T>
[src]
fn values(&self) -> Values<T>
Returns an iterator over node values in creation order.
fn values_mut(&mut self) -> ValuesMut<T>
Returns a mutable iterator over node values in creation order.
fn into_values(self) -> IntoValues<T>
Returns an iterator that moves node values out of the tree in creation order.
fn nodes(&self) -> Nodes<T>
Returns an iterator over all nodes, including orphans, in creation order.
impl<T> Tree<T>
[src]
fn new(root: T) -> Self
Creates a new tree with a root node.
fn with_capacity(root: T, capacity: usize) -> Self
Creates a new tree of the specified capacity with a root node.
fn root(&self) -> NodeRef<T>
Returns a reference to the root node.
fn root_mut(&mut self) -> NodeMut<T>
Returns a mutator of the root node.
fn orphan(&mut self, value: T) -> NodeMut<T>
Creates an orphan node, returning a mutator of it.
fn get(&self, id: NodeId<T>) -> NodeRef<T>
Returns a reference to the specified node.
Panics
Panics if id
does not refer to a node in this tree.
fn get_mut(&mut self, id: NodeId<T>) -> NodeMut<T>
Trait Implementations
impl<T: Debug> Debug for Tree<T>
[src]
impl<T: Default> Default for Tree<T>
[src]
impl<T: Clone> Clone for Tree<T>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more