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
//! # basic_tree
//!
//! `basic_tree` is the trie lib for rust ,
//! which utilizes Rc and Refcell to implemented
//!
//! # Examples
//!
//! ## [Word Trie](trie/word/struct.WordTrie.html)
//!
//! 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](trie/basic/struct.Node.html)
//!
//! 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](trie/basic/trait.Trie.html)
//! the basic trie trait.
//! you can implement your own trie structure based on this trait.
//!
//!
/// trie mod to implement the basic_tree