common-tree 0.2.0

common tree lib
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 11.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • chanble/common-tree
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chanble

common tree 树结构

通用树结构库, 是现实了深度遍历(preorder, 先序遍历)和广度优先遍历

usage 用法

更多可以查看examples


use common_tree::Node;

struct NodeData {
    id: usize,
    name: String,
}

impl NodeData {
    pub fn new(id: usize, name: String) -> Self {
        Self {
            id,
            name,
        }
    }

    pub fn print(&self) {
        println!("id: {}, name: {}", self.id, self.name);
    }
}
type HellNode = Node<NodeData>;

fn main() {

    let root = HellNode::new(NodeData::new(0, format!("root")));

    root.data().print();

}

run examples

cargo run --example hello