#trie #tree #basic #tree-structure #now #node #word

basic_tree

basic tree for rust, for now including only trie

6 releases

0.2.5 Oct 22, 2019
0.2.4 Oct 22, 2019

#51 in #now

22 downloads per month

MIT license

785KB
364 lines

Contains (WOFF font, 190KB) doc/FiraSans-Medium.woff, (WOFF font, 185KB) doc/FiraSans-Regular.woff, (WOFF font, 94KB) doc/SourceSerifPro-Bold.ttf.woff, (WOFF font, 89KB) doc/SourceSerifPro-Regular.ttf.woff, (WOFF font, 56KB) doc/SourceCodePro-Regular.woff, (WOFF font, 56KB) doc/SourceCodePro-Semibold.woff and 1 more.

Basic_Tree

Crate

A Rust library for tree structure.

Basic_tree provides the basic tree implementation.

For now, it only implement a trie tree

Usage

Add this to your Cargo.toml:

[dependencies]
basic_tree = "*"

instructions

this lib is just a personal work, hope it can help you


lib.rs:

basic_tree

basic_tree is the trie lib for rust , which utilizes Rc and Refcell to implemented

Examples

Word Trie

used for constructing word level trie

let word_trie = basic_tree::trie::word::WordTrie::new();
let seq = "你在干什么";
let seq1 = "你在找什么";
word_trie.insert_words(seq, "没干嘛");
word_trie.insert_words(seq1, "是吗");
println!("{:?}", word_trie);

Node Trie

used for constructing char level trie

let node = basic_tree::trie::basic::Node::new();
let seq = vec!["".to_string(), "".to_string(), "".to_string()];
let seq1 = vec!["".to_string(), "".to_string()];
Node::insert_seq(node.clone(), &seq, Leaf::End("intention".to_string()));
let leaf = Node::get_leaf(node.clone(), &seq1);
assert_ne!(leaf, Leaf::End("intention".to_string()));

Trie trait

the basic trie trait. you can implement your own trie structure based on this trait.

No runtime deps