|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Node
Specifies the methods that nodes must implement.
The main function of a node is to represent an "edge" in the tree. An edge is a connection from a parent node to a child node which represents a sequence of characters. For practical reasons we store these characters in the child node, to avoid needing separate Edge objects. All nodes except the root encode at least one character for an edge. Nodes contain several fields, but not all nodes will actually need to store values in every field. Therefore some specialized implementations of this interface are possible, optimized for storing various combinations of data items in reduced numbers of fields, to reduce memory overhead. Nodes are partially immutable:CharSequence object verbatim, or use a particular implementation of
CharSequence, the only requirement is that they provide a CharSequence view onto
the character data.
Character data can optionally be stored outside of the tree. CharSequences can encode a start and
end offset (or length) as a view onto a larger string (possibly a view onto the original key inserted).
Furthermore end offset could be stored as length, relative to the start offset with variable length encoding
to avoid storing 4 bytes for the length. This option would have consequences for
garbage collection of large string keys however, therefore would mostly suit immutable data sets.
Character data can be compressed. CharSequences are free to store character data within the tree but
in a size-reduced encoding such as UTF-8
| Method Summary | |
|---|---|
CharSequence |
getIncomingEdge()
Returns all characters of the "edge" encoded in this node, belonging to the connection from a parent node to this node. |
Character |
getIncomingEdgeFirstCharacter()
Returns the first character of the "edge" encoded in this node, belonging to the connection from a parent node to this node. |
Node |
getOutgoingEdge(Character edgeFirstCharacter)
Returns the child of this node whose edge starts with the given first character. |
List<Node> |
getOutgoingEdges()
Returns a read-only list of the child nodes to which this node has outgoing edges, i.e. |
Object |
getValue()
Returns a value object which has been associated with a key and which is stored in this node, or returns null if no value is stored in this node. |
void |
updateOutgoingEdge(Node childNode)
Updates the child node reference for a given edge (identified by its first character) to point to a different child node. |
| Method Detail |
|---|
Character getIncomingEdgeFirstCharacter()
getIncomingEdgeFirstCharacter in interface NodeCharacterProviderCharSequence getIncomingEdge()
Object getValue()
null if no value is stored in this node.
null if no value is stored in this nodeNode getOutgoingEdge(Character edgeFirstCharacter)
updateOutgoingEdge(Node).
edgeFirstCharacter - The first character of the edge for which the associated child node is required
null if this
node has no such outgoing edgevoid updateOutgoingEdge(Node childNode)
getOutgoingEdge(Character).
childNode - The new child node to associated with this edgeList<Node> getOutgoingEdges()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||