Crates.io | xtree |
lib.rs | xtree |
version | 0.1.8 |
source | src |
created_at | 2021-01-03 17:22:47.191743 |
updated_at | 2021-01-04 16:09:44.267482 |
description | A simple general purpose tree data structure. |
homepage | https://github.com/xstater/xtree |
repository | https://github.com/xstater/xtree |
max_upload_size | |
id | 331110 |
size | 22,716 |
A simple rust general purpose tree data structure.
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
for value in tree.df_iter(){
print!("{} ",value);
}
It will print 1 2 3 4 5
in console.
for value in tree.bf_iter_mut(){
*value += 1;
print!("{} ",value);
}
It will print 2 3 6 4 5
in console.
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.