Class DefaultCharSequenceNodeFactory
java.lang.Object
com.googlecode.concurrenttrees.radix.node.concrete.DefaultCharSequenceNodeFactory
- All Implemented Interfaces:
NodeFactory, Serializable
A
NodeFactory which creates various implementations of Node objects all of which store incoming
edge characters as a CharSequence (a view onto the original key) rather than copying the edge into a
character array.
Returns an optimal node implementation depending on arguments supplied, which will be one of:
CharSequenceNodeDefault- contains all possible fieldsCharSequenceNodeNonLeafNullValue- does not store a value, returnsnullfor valueCharSequenceNodeNonLeafVoidValue- does not store a value, returnsVoidValuefor valueCharSequenceNodeLeafVoidValue- does not store child edges or a value, returnsVoidValuefor valueCharSequenceNodeLeafWithValue- does not store child edges, but does store a value
VoidValue for a value, this factory will omit actually storing that value
in the tree and will return one of the Void-optimized nodes above which can reduce memory usage.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateNode(CharSequence edgeCharacters, Object value, List<Node> childNodes, boolean isRoot)
-
Constructor Details
-
DefaultCharSequenceNodeFactory
public DefaultCharSequenceNodeFactory()
-
-
Method Details
-
createNode
public Node createNode(CharSequence edgeCharacters, Object value, List<Node> childNodes, boolean isRoot) Description copied from interface:NodeFactoryReturns a newNodeobject which encapsulates the arguments supplied, optionally returning implementations of theNodeinterface which are memory-optimized for storing only the supplied combination of variables, potentially further optimized based on variable values.- Specified by:
createNodein interfaceNodeFactory- Parameters:
edgeCharacters- Provides edge characters to be stored in the node. This is never null. In the case of (re-)constructing the root node, this will contain zero characters, otherwise will always contain one or more charactersvalue- An arbitrary object to associate with the node. This can be null, but it will not be null if dealing with a leaf node (when childNodes will be empty)childNodes- A list of child nodes to store in the node. This will never be null, but may be empty when building a leaf nodeisRoot- Indicates if this will be the root node, in which case edge characters will be non-null but empty, value will be null, and child nodes will be non-null but may be empty- Returns:
- An object implementing the
Nodeinterface which stores the given variables
-