|
36 | 36 | //! tree.insert(Node::new(3), UnderNode(&child_id)).unwrap(); |
37 | 37 | //! tree.insert(Node::new(4), UnderNode(&child_id)).unwrap(); |
38 | 38 | //! |
39 | | -//! println!("Pre-order:"); |
40 | | -//! print_pre_order(&tree, &root_id); |
41 | | -//! // results in the output "0, 1, 3, 4, 2, " |
42 | | -//! } |
43 | | -//! |
44 | | -//! fn print_pre_order(tree: &Tree<i32>, node_id: &NodeId) { |
45 | | -//! let node_ref = tree.get(node_id).unwrap(); |
46 | | -//! |
47 | | -//! print!("{}, ", node_ref.data()); |
48 | | -//! |
49 | | -//! for child_id in node_ref.children() { |
50 | | -//! print_pre_order(tree, &child_id); |
| 39 | +//! println!("Post-order:"); |
| 40 | +//! for node in tree.traverse_pre_order(&root_id).unwrap() { |
| 41 | +//! print!("{}, ", node.data()); |
51 | 42 | //! } |
| 43 | +//! // results in the output "0, 1, 3, 4, 2, " |
52 | 44 | //! } |
53 | 45 | //! ``` |
54 | 46 | //! |
@@ -90,6 +82,13 @@ pub use node::NodeBuilder; |
90 | 82 | pub use node::Node; |
91 | 83 | pub use tree::TreeBuilder; |
92 | 84 | pub use tree::Tree; |
| 85 | +pub use tree::iterators::Ancestors; |
| 86 | +pub use tree::iterators::AncestorIds; |
| 87 | +pub use tree::iterators::Children; |
| 88 | +pub use tree::iterators::ChildrenIds; |
| 89 | +pub use tree::iterators::PreOrderTraversal; |
| 90 | +pub use tree::iterators::PostOrderTraversal; |
| 91 | +pub use tree::iterators::LevelOrderTraversal; |
93 | 92 |
|
94 | 93 | /// |
95 | 94 | /// An identifier used to differentiate between `Node`s within a `Tree`. |
|
0 commit comments