com.googlecode.concurrenttrees.radix.node
Interface Node

All Superinterfaces:
NodeCharacterProvider
All Known Implementing Classes:
ByteArrayNodeDefault, ByteArrayNodeLeafNullValue, ByteArrayNodeLeafVoidValue, ByteArrayNodeLeafWithValue, ByteArrayNodeNonLeafNullValue, ByteArrayNodeNonLeafVoidValue, CharArrayNodeDefault, CharArrayNodeLeafNullValue, CharArrayNodeLeafVoidValue, CharArrayNodeLeafWithValue, CharArrayNodeNonLeafNullValue, CharArrayNodeNonLeafVoidValue, CharSequenceNodeDefault, CharSequenceNodeLeafNullValue, CharSequenceNodeLeafVoidValue, CharSequenceNodeLeafWithValue, CharSequenceNodeNonLeafNullValue, CharSequenceNodeNonLeafVoidValue

public interface Node
extends NodeCharacterProvider

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:

These constraints exist allow concurrent traversal and modifications to the tree. Nodes are required to implement some operations atomically, see documentation on each method in this interface for details.

Hints for specialized implementations of this Node interface:

Author:
Niall Gallagher

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

getIncomingEdgeFirstCharacter

Character getIncomingEdgeFirstCharacter()
Returns the first character of the "edge" encoded in this node, belonging to the connection from a parent node to this node.

Specified by:
getIncomingEdgeFirstCharacter in interface NodeCharacterProvider
Returns:
The first character of the "edge" encoded in this node

getIncomingEdge

CharSequence getIncomingEdge()
Returns all characters of the "edge" encoded in this node, belonging to the connection from a parent node to this node.

Returns:
All characters of the "edge" encoded in this node

getValue

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.

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

getOutgoingEdge

Node getOutgoingEdge(Character edgeFirstCharacter)
Returns the child of this node whose edge starts with the given first character.

This read must be performed atomically, in relation to writes made via updateOutgoingEdge(Node).

Parameters:
edgeFirstCharacter - The first character of the edge for which the associated child node is required
Returns:
The child of this node whose edge starts with the given first character, or null if this node has no such outgoing edge

updateOutgoingEdge

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.

The first character of the given child node's edge must match the first character of an existing outgoing edge from this node.

This write must be performed atomically, in relation to reads made via getOutgoingEdge(Character).

Parameters:
childNode - The new child node to associated with this edge

getOutgoingEdges

List<Node> getOutgoingEdges()
Returns a read-only list of the child nodes to which this node has outgoing edges, i.e. child nodes which have incoming edges from this node.

It is intended that this method will be used for copying/cloning nodes.

Returns:
A read-only list of the child nodes to which this node has outgoing edges


Copyright © 2013. All Rights Reserved.