|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.concurrenttrees.radix.node.concrete.charsequence.CharSequenceNodeDefault
public class CharSequenceNodeDefault
A implementation of the Node interface which stores the incoming edge as a CharSequence (a
view onto the original key) rather than copying the edge into a character array. Stores all variables and
supports all behaviours required by the tree, but still could be more memory efficient.
NodeFactory for documentation on how alternative
node implementations can be created to reduce memory overhead. See the Node interface for details on how
to write memory-efficient nodes.
This implementation stores references to child nodes in an AtomicReferenceArray, in ascending sorted order
of the first character of the edges which child nodes define.
The getOutgoingEdge(Character) method uses binary search to locate a requested node, given the first character
of an edge indicated. The node is then read and returned atomically from the AtomicReferenceArray.
The updateOutgoingEdge(com.googlecode.concurrenttrees.radix.node.Node) method ensures that any
attempt to update a reference to a child node preserves the constraints defined in the Node interface. New
child nodes are written atomically to the AtomicReferenceArray.
The constraints defined in the Node interface ensure that the AtomicReferenceArray always remains in
ascending sorted order regardless of modifications performed concurrently, as long as the modifications comply with
the constraints. This node enforces those constraints.
| Constructor Summary | |
|---|---|
CharSequenceNodeDefault(CharSequence edgeCharSequence,
Object value,
List<Node> outgoingEdges)
|
|
| 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. |
String |
toString()
|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CharSequenceNodeDefault(CharSequence edgeCharSequence,
Object value,
List<Node> outgoingEdges)
| Method Detail |
|---|
public CharSequence getIncomingEdge()
Node
getIncomingEdge in interface Nodepublic Character getIncomingEdgeFirstCharacter()
Node
getIncomingEdgeFirstCharacter in interface NodegetIncomingEdgeFirstCharacter in interface NodeCharacterProviderpublic Object getValue()
Nodenull if no value is stored in this node.
getValue in interface Nodenull if no value is stored in this nodepublic Node getOutgoingEdge(Character edgeFirstCharacter)
NodeNode.updateOutgoingEdge(Node).
getOutgoingEdge in interface NodeedgeFirstCharacter - The first character of the edge for which the associated child node is required
null if this
node has no such outgoing edgepublic void updateOutgoingEdge(Node childNode)
NodeNode.getOutgoingEdge(Character).
updateOutgoingEdge in interface NodechildNode - The new child node to associated with this edgepublic List<Node> getOutgoingEdges()
Node
getOutgoingEdges in interface Nodepublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||