pub struct Node<T: Eq + Hash + Clone> {
pub node: HashMap<T, Rc<RefCell<Node<T>>>>,
pub leaf: Leaf<T>,
}
Expand description
Adds one to the number given.
§Examples
Trie is the basic trait to implement for a trie tree
let node = 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()));
Fields§
§node: HashMap<T, Rc<RefCell<Node<T>>>>
§leaf: Leaf<T>
Implementations§
Trait Implementations§
Source§impl<T: Eq + Hash + Clone> Trie<T> for Node<T>
impl<T: Eq + Hash + Clone> Trie<T> for Node<T>
Source§fn insert_seq(node: Rc<RefCell<Node<T>>>, words: &[T], leaf: Leaf<T>)
fn insert_seq(node: Rc<RefCell<Node<T>>>, words: &[T], leaf: Leaf<T>)
add node chars and leaf chars to Node.
Source§fn get_leaf(node: Rc<RefCell<Node<T>>>, words: &[T]) -> Leaf<T>
fn get_leaf(node: Rc<RefCell<Node<T>>>, words: &[T]) -> Leaf<T>
get the corresponding leaf from the char seq.
Source§fn find_node(
node: Rc<RefCell<Node<T>>>,
word: &T,
) -> (bool, Rc<RefCell<Node<T>>>)
fn find_node( node: Rc<RefCell<Node<T>>>, word: &T, ) -> (bool, Rc<RefCell<Node<T>>>)
get the node correspongding to char.
Auto Trait Implementations§
impl<T> Freeze for Node<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Node<T>
impl<T> !Send for Node<T>
impl<T> !Sync for Node<T>
impl<T> Unpin for Node<T>where
T: Unpin,
impl<T> !UnwindSafe for Node<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more