Package com.github.underscore
Class Trie
- java.lang.Object
-
- com.github.underscore.Trie
-
public class Trie extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Trie.TrieNode
-
Field Summary
Fields Modifier and Type Field Description private Trie.TrieNode
root
private boolean
startWith
-
Constructor Summary
Constructors Constructor Description Trie()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
insert(String word)
private void
insert(String word, Trie.TrieNode root, int idx)
boolean
search(String word)
boolean
search(String word, Trie.TrieNode root, int idx)
boolean
startsWith(String prefix)
-
-
-
Field Detail
-
root
private final Trie.TrieNode root
-
startWith
private boolean startWith
-
-
Method Detail
-
insert
public void insert(String word)
-
insert
private void insert(String word, Trie.TrieNode root, int idx)
-
search
public boolean search(String word)
-
search
public boolean search(String word, Trie.TrieNode root, int idx)
-
startsWith
public boolean startsWith(String prefix)
-
-