Class NodeUtil
java.lang.Object
com.googlecode.concurrenttrees.radix.node.util.NodeUtil
Static utility methods useful when implementing
Node
s.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
binarySearchForEdge
(AtomicReferenceArray<Node> childNodes, Character edgeFirstCharacter) Returns the index of the node in the givenAtomicReferenceArray
whose edge starts with the given first character.static void
ensureNoDuplicateEdges
(List<Node> nodes) Throws an exception if any nodes in the given list represent edges having the same first character.
-
Constructor Details
-
NodeUtil
NodeUtil()Private constructor, not used.
-
-
Method Details
-
binarySearchForEdge
public static int binarySearchForEdge(AtomicReferenceArray<Node> childNodes, Character edgeFirstCharacter) Returns the index of the node in the givenAtomicReferenceArray
whose edge starts with the given first character. This method expects that some constraints are enforced on theAtomicReferenceArray
:- The array must already be in ascending sorted order of the first character of the edge for each node
- No entries in the array can be null
- Any existing node in the array cannot be swapped concurrently for another unless the edge associated with the other node also starts with the same first character
- Parameters:
childNodes
- AnAtomicReferenceArray
ofNode
objects, which is used in accordance with the constraints documented in this methodedgeFirstCharacter
- The first character of the edge for which the associated node is required- Returns:
- The index of the node representing the indicated edge, or a value invalid input: '<' 0 if no such node exists in the array
-
ensureNoDuplicateEdges
Throws an exception if any nodes in the given list represent edges having the same first character.- Parameters:
nodes
- The list of nodes to validate- Throws:
IllegalStateException
- If a duplicate edge is detected
-