protected static class StringDecoder.Node extends Object
Each node holds its value and several pointers:
myNext
and myPrevious
values are the pointers
to the next and previous elements in the recent linked list.myParent
is the parent of this node. For the root nodes
this is null.myChildren
is a two dimension array for the children of this
node. We use a 2 dimension array to reduce the memory footprint of the
trie by taking advantage of the clustering within the encoding of
languages. The first dimension of the array we refer to as the
zone
and represents the first/high nibble of the value for the
child node. The second dimension of the array is the second/low nibble.Constructor and Description |
---|
StringDecoder.Node(StringDecoder.Node parent,
byte value)
Creates a new Node.
|
Modifier and Type | Method and Description |
---|---|
void |
addAfter(StringDecoder.Node node)
Add a node after the provided node.
|
void |
addChild(StringDecoder.Node child)
Adds a child node to this node.
|
StringDecoder.Node |
child(byte value)
Returns the child node with the specified value.
|
String |
getDecoded()
Returns the node's decoded value.
|
StringDecoder.Node |
getNext()
Returns the next node in the recent list.
|
StringDecoder.Node |
getPrevious()
Returns the previous node in the recent list.
|
byte |
getValue()
Returns the node's value.
|
int |
remove()
Removes the node and its children from the trie.
|
void |
removeFromList()
Removes the node from the recent linked list.
|
void |
setDecoded(String decoded)
Sets the decoded value for the node.
|
public StringDecoder.Node(StringDecoder.Node parent, byte value)
parent
- The parent node. May be null
.value
- The value for the node.public void addAfter(StringDecoder.Node node)
node
- The head node.public void addChild(StringDecoder.Node child)
child
- The child node to add.public StringDecoder.Node child(byte value)
value
- The value for the child to find.public String getDecoded()
public StringDecoder.Node getNext()
public StringDecoder.Node getPrevious()
public byte getValue()
public int remove()
public void removeFromList()
public void setDecoded(String decoded)
decoded
- The decoded value for the node.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.