Package com.tangosol.util
Class AbstractSparseArray.Node<V>
- java.lang.Object
-
- com.tangosol.util.AbstractSparseArray.Node<V>
-
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
PrimitiveSparseArray.PrimitiveNode,SparseArray.ObjectNode
- Enclosing class:
- AbstractSparseArray<V>
protected abstract static class AbstractSparseArray.Node<V> extends Object implements Cloneable, Serializable
An AVL tree node. This class is used only within the AbstractSparseArray class and its derivations.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intbalanceThe AVL balance factor of the sub-tree.protected longkeyThe key of the node.protected AbstractSparseArray.Node<V>leftThe left child of this node.protected AbstractSparseArray.Node<V>parentThe parent of this node.protected AbstractSparseArray.Node<V>rightThe right child of this node.
-
Constructor Summary
Constructors Modifier Constructor Description protectedNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidadopt(AbstractSparseArray.Node<V> child, boolean fLeft)Adopt a child nodeAbstractSparseArray.Node<V>clone()Make a shallow copy of the node and its sub-nodes.abstract VgetValue()Get the value associated with the node.protected booleanisLeaf()Determine if this node is a part of a 2-3-4 leaf node (i.e. at least one null child).protected booleanisLinked()Return true iff the node is linked to other nodes.protected voidprint()Print the tree structure.abstract VsetValue(V oValue)Set the value associated with the node.StringtoString()Provide a string representation of this node's value.protected intvalidate()Validate the tree rooted at node is a proper AVL tree.
-
-
-
Field Detail
-
key
protected long key
The key of the node. The key, once set, is considered immutable.
-
parent
protected AbstractSparseArray.Node<V> parent
The parent of this node.
-
left
protected AbstractSparseArray.Node<V> left
The left child of this node.
-
right
protected AbstractSparseArray.Node<V> right
The right child of this node.
-
balance
protected int balance
The AVL balance factor of the sub-tree.
-
-
Method Detail
-
adopt
protected void adopt(AbstractSparseArray.Node<V> child, boolean fLeft)
Adopt a child node- Parameters:
child- the child to adoptfLeft- the position of the child
-
getValue
public abstract V getValue()
Get the value associated with the node.- Returns:
- the value associated with the node.
-
setValue
public abstract V setValue(V oValue)
Set the value associated with the node.- Parameters:
oValue- the value associated with the node- Returns:
- the old value associated with the node
-
toString
public String toString()
Provide a string representation of this node's value.
-
clone
public AbstractSparseArray.Node<V> clone()
Make a shallow copy of the node and its sub-nodes.
-
isLeaf
protected boolean isLeaf()
Determine if this node is a part of a 2-3-4 leaf node (i.e. at least one null child).- Returns:
- true if this node is a leaf
-
isLinked
protected boolean isLinked()
Return true iff the node is linked to other nodes.- Returns:
- true iff the node has a parent or children
-
print
protected void print()
Print the tree structure.
-
validate
protected int validate()
Validate the tree rooted at node is a proper AVL tree.- Returns:
- the height of the node within the tree
-
-