[−][src]Crate trees
General purpose tree library. See the trees book for more.
Examples
The code below construct the following tree in different ways:
.............
. 0 .
. / \ .
. 1 4 .
. / \ / \ .
.2 3 5 6.
.............
Example of tr
notations for building trees
use trees::tr; let tree = tr(0) /( tr(1)/tr(2)/tr(3) ) /( tr(4)/tr(5)/tr(6) );
Example of tuple notations for building trees
let tree = trees::Tree::<i32>::from_tuple(( 0, (1,2,3), (4,5,6) ));
Example of building trees step by step
use trees::Tree; let mut tree = Tree::new(0); let mut root = tree.root_mut(); root.push_back( Tree::new(1) ); root.push_back( Tree::new(4) ); let mut children = root.iter_mut(); let mut node_1 = children.next().unwrap(); node_1.push_back( Tree::new(2) ); node_1.push_back( Tree::new(3) ); let mut node_4 = children.next().unwrap(); node_4.push_back( Tree::new(5) ); node_4.push_back( Tree::new(6) );
Overview of features
-
Step-by-step creating, reading, updating, deleting and iterating nodes with assocated data items.
-
Compact notations to express trees:
-
,/
encoded or tuple encoded trees. -
Depth first search cursor.
-
Breadth first search iterators.
-
Trees can be built by stages, with nodes stored scatteredly among memory.
-
Trees can be built once through, with nodes stored contiguously.
-
Support exclusive ownership with static borrow check.
-
Support shared ownership with dynamic borrow check.
Re-exports
pub use tuple::TupleForest; |
pub use tuple::TupleTree; |
pub use size::Size; |
pub use tree::Tree; |
pub use forest::Forest; |
pub use node::Node; |
pub use iter::Iter; |
pub use iter::IterMut; |
pub use into_iter::IntoIter; |
pub use walk::TreeWalk; |
pub use walk::ForestWalk; |
pub use notation::tr; |
pub use notation::fr; |
pub use iter_rc::IterRc; |
pub use rc::RcNode; |
pub use rc::WeakNode; |
Modules
bfs | Breadth first search. |
forest | Composed of a list of |
into_iter | Forest's owning iterator. |
iter | Iterators of |
iter_rc | Iterators of |
node | Composed of |
notation | Operator overloading of |
rc | Reference-counting nodes. |
size | size of a tree/forest/node, including degree and descendant node count |
tree | Composed of a root |
tuple | Traits for implementing tuple notations |
walk | Depth first search in |