Expand description
§XTree
XTree is a general purpose tree data structure.
§Homepage
§Documentions
§Sources
§Construct a tree
extern crate xtree;
use xtree::*;
let tree =
tr!(1)
/ (tr!(2)
/ tr!(3)
/ tr!(4))
/ tr!(5);
It will construct a tree like below
// 1
// / \
// 2 5
// / \
// 3 4
§Depth-First iterate a tree
for value in tree.df_iter(){
print!("{} ",value);
}
It will print 1 2 3 4 5
in console.
§Breadth-First iterate a tree and Change the value
for value in tree.bf_iter_mut(){
*value += 1;
print!("{} ",value);
}
It will print 2 3 6 4 5
in console.
§Freely visit node with Cursor
let mut cursor = tree.cursor();
create a read-only cursor to root node.
cursor.move_child(0);
move this cursor to the first child node.
println!("{}",cursor.current());
get the value of which it pointing now.
it will print 2
in console.
§Advanced usage
Macros§
- tr
- A useful macro is used to build a tree
Structs§
- BfDepth
Iter - The immutable Breadth-First Iterator with Depth information.
- BfDepth
Iter Mut - The mutable Breadth-First Iterator with Depth information.
- BfIter
- The immutable Breadth-First Iterator.
- BfIter
Mut - The mutable Breadth-First Iterator.
- Children
Iter - The immutable iterator over all the children
- Children
Iter Mut - The mutable iterator over all the children
- Cursor
- A immutable Cursor can freely visit node in tree
- Cursor
Mut - A mutable Cursor can freely visit node in tree
- DfDepth
Iter - The immutable Depth-First Iterator with Depth information.
- DfDepth
Iter Mut - The mutable Breadth-First Iterator with Depth information.
- DfIter
- The immutable Depth-First Iterator.
- DfIter
Mut - The mutable Depth-First Iterator.
- Tree
- The type representing a Tree