T - payload data typepublic class TrieNode<T extends Serializable> extends Object implements Serializable
Trie. The nodes are organized horizontal (each node can
get the next brother node) and vertical (each node can get the first son). | Modifier and Type | Class and Description |
|---|---|
static class |
TrieNode.TrieNodeBrothersIterable<T extends Serializable>
Iterable to iterate over a node and all its next brothers.
|
static class |
TrieNode.TrieNodeDescendantsIterable<T extends Serializable>
Iterable to iterate over a node and all its descendants (all children and
children's children).
|
static interface |
TrieNode.TrieNodeIterable<T extends Serializable>
Interface for itable classes with stream support for
TrieNodes. |
| Constructor and Description |
|---|
TrieNode(char[] chars,
TrieNode<T> brother,
TrieNode<T> son,
T data,
boolean inserted)
Create new trie node.
|
TrieNode(String chars,
TrieNode<T> brother,
TrieNode<T> son,
T data,
boolean inserted)
Create new trie node.
|
| Modifier and Type | Method and Description |
|---|---|
TrieNode.TrieNodeIterable<T> |
brothers()
Get iterable (for use in foreach loop) to iterate over this node and all
of its next brothers.
|
TrieNode.TrieNodeIterable<T> |
children()
Get iterable (for use in foreach loop) to iterate over all children of
this node.
|
TrieNode.TrieNodeIterable<T> |
descendants()
Get iterable (for use in foreach loop) to iterate over the node and all
of its descendants (its children and their children and so on).
|
char[] |
getChars()
Get the characters leading from the parent ot this node.
|
T |
getData()
Get payload data of the node.
|
int |
getDepth()
Calculate the depth of the tree starting from this node.
|
char |
getFirstChar()
Get the first character of the characters loading from the parent to this
node.
|
TrieNode<T> |
getFirstSon()
Get the first son of this node.
|
TrieNode<T> |
getNextBrother()
Get the next brother of this node.
|
boolean |
hasBrothers()
Check if a node has next brothers.
|
boolean |
hasChildren()
Check if a node has children.
|
boolean |
hasData()
Check if a node has data attached to it.
|
boolean |
isInserted()
Get flag if node represents an inserted string in the trie.
|
void |
setChars(char[] chars)
Set the characters leading from the parent ot this node.
|
void |
setData(T data)
Set payload data of the node.
|
void |
setFirstSon(TrieNode<T> firstSon)
Set the first son of this node.
|
void |
setInserted(boolean inserted)
Set flag if node represents an inserted string in the trie.
|
void |
setNextBrother(TrieNode<T> nextBrother)
Set the next brother of this node.
|
String |
toString()
Render the tree starting from this node as String.
|
String |
toString(String indentation) |
public TrieNode(char[] chars,
TrieNode<T> brother,
TrieNode<T> son,
T data,
boolean inserted)
chars - chars containing the path leading from the parent node to this
nodebrother - next brother (optional)son - first son (optional)data - playload data (optional)inserted - true if the node was introduced as leaf of an insert operationpublic TrieNode(String chars, TrieNode<T> brother, TrieNode<T> son, T data, boolean inserted)
chars - String containing the path leading from the parent node to
this nodebrother - next brother (optional)son - first son (optional)data - playload data (optional)inserted - true if the node was introduced as leaf of an insert operationpublic char[] getChars()
public void setChars(char[] chars)
chars - character arraypublic TrieNode<T> getFirstSon()
public void setFirstSon(TrieNode<T> firstSon)
firstSon - trie node or nullpublic TrieNode<T> getNextBrother()
public void setNextBrother(TrieNode<T> nextBrother)
nextBrother - trie node or nullpublic T getData()
public void setData(T data)
data - playload data or nullpublic boolean isInserted()
public void setInserted(boolean inserted)
inserted - true if node represents an inserted stringpublic boolean hasChildren()
public boolean hasBrothers()
public boolean hasData()
public char getFirstChar()
public int getDepth()
public TrieNode.TrieNodeIterable<T> brothers()
public TrieNode.TrieNodeIterable<T> children()
public TrieNode.TrieNodeIterable<T> descendants()
public String toString()
Copyright © 2015 illucIT Software GmbH. All rights reserved.