Class NodeUtil
- java.lang.Object
-
- com.googlecode.concurrenttrees.radix.node.util.NodeUtil
-
public class NodeUtil extends java.lang.ObjectStatic utility methods useful when implementingNodes.
-
-
Constructor Summary
Constructors Constructor Description NodeUtil()Private constructor, not used.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbinarySearchForEdge(java.util.concurrent.atomic.AtomicReferenceArray<Node> childNodes, java.lang.Character edgeFirstCharacter)Returns the index of the node in the givenAtomicReferenceArraywhose edge starts with the given first character.static voidensureNoDuplicateEdges(java.util.List<Node> nodes)Throws an exception if any nodes in the given list represent edges having the same first character.
-
-
-
Method Detail
-
binarySearchForEdge
public static int binarySearchForEdge(java.util.concurrent.atomic.AtomicReferenceArray<Node> childNodes, java.lang.Character edgeFirstCharacter)
Returns the index of the node in the givenAtomicReferenceArraywhose 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- AnAtomicReferenceArrayofNodeobjects, 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 < 0 if no such node exists in the array
-
ensureNoDuplicateEdges
public static void ensureNoDuplicateEdges(java.util.List<Node> nodes)
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:
java.lang.IllegalStateException- If a duplicate edge is detected
-
-