| Constructor and Description |
|---|
TrieNode(char c)
Create a new node with the given character and no children.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(java.lang.String word) |
static <T> TrieNode<T> |
createRoot()
Create a node representing the root node of a Trie.
|
static <T> TrieNode<T> |
emptyTrie() |
java.util.Set<java.util.Map.Entry<java.lang.String,T>> |
entrySet() |
Trie<T> |
filter(Pred<T> filter) |
Opt<T> |
get(java.lang.String word) |
java.lang.String |
getLongestPrefix() |
boolean |
isEmpty() |
<A> TrieNode<A> |
mapValues(Func<T,A> function) |
int |
size() |
Trie<T> |
subTrie(java.lang.String prefix) |
java.util.Map<java.lang.String,T> |
toMap() |
java.lang.String |
toString() |
Trie<T> |
union(Trie<T> other) |
java.util.Collection<T> |
values() |
void |
visitWords(TrieVisitor<T> visitor)
Calls
TrieVisitor.visit(java.lang.String, T) for each word-value pair in this Trie. |
java.util.Collection<java.lang.String> |
words() |
public TrieNode(char c)
c - Character to assign to this node.public int size()
public boolean isEmpty()
public boolean contains(java.lang.String word)
public java.lang.String getLongestPrefix()
getLongestPrefix in interface Trie<T>public <A> TrieNode<A> mapValues(Func<T,A> function)
mapValues in interface Trie<T>A - Type to transform values to.function - Function to apply to each value in this Trie.Func.apply(T).public Trie<T> filter(Pred<T> filter)
filter in interface Trie<T>filter - Predicate that determines which values to keep in the Trie.Pred.test(T) returned true.public Trie<T> union(Trie<T> other)
union in interface Trie<T>other - The other Trie of the union.public void visitWords(TrieVisitor<T> visitor)
TrieTrieVisitor.visit(java.lang.String, T) for each word-value pair in this Trie.visitWords in interface Trie<T>visitor - The visitor that will visit each word-value pair.public java.util.Collection<java.lang.String> words()
public java.util.Collection<T> values()
public java.util.Set<java.util.Map.Entry<java.lang.String,T>> entrySet()
public java.util.Map<java.lang.String,T> toMap()
public java.lang.String toString()
toString in class java.lang.Objectpublic static <T> TrieNode<T> createRoot()
T - Trie type.public static <T> TrieNode<T> emptyTrie()
T - Trie type.