1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
//! # XTree //! XTree is a general purpose tree data structure. //! ## 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.<br> //! it will print ```2``` in console. //! ## Advanced usage //! [More exmples](https://github.com/xstater/xtree/tree/master/examples) mod tree; mod cursor; mod df_iter; mod bf_iter; pub use tree::Tree; pub use cursor::{Cursor,CursorMut}; pub use df_iter::*; pub use bf_iter::*;