public class Trie.Node
extends java.lang.Object
Constructor and Description |
---|
Node()
Constructor
|
Node(char key)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String value)
Add string to add to this node
|
void |
add(java.lang.String value,
boolean terminate) |
Trie.Node |
addChild(Trie.Node newNode)
Adds a new child node to this node
|
java.util.List<Trie.Node> |
getChildren()
Returns this node's child nodes
|
char |
getKey()
Return this node's key
|
boolean |
hasSinglePath()
Predicate indicating if children following this node forms single key path (no branching)
|
public Node()
public Node(char key)
key
- this node's keypublic void add(java.lang.String value)
value
- string value, not nullpublic void add(java.lang.String value, boolean terminate)
public Trie.Node addChild(Trie.Node newNode)
newNode
- new child to addpublic char getKey()
public boolean hasSinglePath()
For example, if we have "abcde" and "abfgh" in the trie, calling this method on node "a" and "b" returns false. However, this method on "c", "d", "e", "f", "g" and "h" returns true.
public java.util.List<Trie.Node> getChildren()