|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.AbstractLongArray
com.tangosol.util.AbstractSparseArray
public abstract class AbstractSparseArray
A data structure resembling an array indexed by long values, stored as an AVL tree. Implementation is based on the public domain implementation by Julienne Walker. This implementation is not thread-safe.
| Nested Class Summary | |
|---|---|
protected class |
AbstractSparseArray.CrawlerA tree node iterator. |
protected static class |
AbstractSparseArray.NodeAn AVL tree node. |
| Nested classes/interfaces inherited from interface com.tangosol.util.LongArray |
|---|
LongArray.Iterator |
| Field Summary | |
|---|---|
protected AbstractSparseArray.Node |
m_headThe first node of the tree (or null if the tree is empty). |
protected int |
m_sizeThe number of nodes in the tree. |
| Fields inherited from interface com.tangosol.util.LongArray |
|---|
NOT_FOUND |
| Constructor Summary | |
|---|---|
AbstractSparseArray()Default constructor. |
|
| Method Summary | |
|---|---|
protected void |
adjustDoubleBalance(AbstractSparseArray.Node node, AbstractSparseArray.Node child, int iBal)Adjust the balance factor of a node and its decendentans prior to a a double rotation. |
protected void |
balancedInsertion(AbstractSparseArray.Node parent, AbstractSparseArray.Node child)Insert a node into a tree and rebalance. |
protected void |
balancePostRemove(AbstractSparseArray.Node pruned, boolean fPrunedLeft)Rebalance the tree following the removal of a node. |
void |
clear()Remove all nodes from the LongArray. |
java.lang.Object |
clone()Make a clone of the LongArray. |
protected AbstractSparseArray.Node |
doubleRotate(AbstractSparseArray.Node node, boolean fLeft)Double rotate a node in a given direction. |
boolean |
exists(long lIndex)Determine if the specified index is in use. |
protected AbstractSparseArray.Node |
find(long lIndex)Find the specified key and return its node. |
protected AbstractSparseArray.Node |
findInsertionPoint(long lIndex)Find the point at which a Node with the specified index would be inserted. |
java.lang.Object |
get(long lIndex)Return the value stored at the specified index. |
long |
getFirstIndex()Determine the first index that exists in the LongArray. |
long |
getLastIndex()Determine the last index that exists in the LongArray. |
int |
getSize()Determine the size of the LongArray. |
protected AbstractSparseArray.Crawler |
instantiateCrawler(AbstractSparseArray.Node head, int fromdir, boolean fForward)Instantate a new Crawler at the specified location and direction. |
protected abstract AbstractSparseArray.Node |
instantiateNode(long lKey, java.lang.Object oValue)Factory pattern: create a new Node with the specified key and value. |
LongArray.Iterator |
iterator()Obtain a LongArray.Iterator of the contents of the LongArray. |
LongArray.Iterator |
iterator(long lIndex)Obtain a LongArray.Iterator of the contents of the LongArray, starting at a particular index such that the first call to next will set the location of the iterator at the first existent index that is greater than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index. |
void |
print()In-order printing of the contents of the SparseArray. |
protected void |
remove(AbstractSparseArray.Node node)Remove the specified node from the tree. |
java.lang.Object |
remove(long lIndex)Remove the specified index from the LongArray, returning its associated value. |
protected AbstractSparseArray.Node |
replace(AbstractSparseArray.Node nodeA, AbstractSparseArray.Node nodeB)Replace one node with another. |
LongArray.Iterator |
reverseIterator()Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices). |
LongArray.Iterator |
reverseIterator(long lIndex)Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices), starting at a particular index such that the first call to next will set the location of the iterator at the first existent index that is less than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index. |
protected AbstractSparseArray.Node |
rotate(AbstractSparseArray.Node node, boolean fLeft)Rotate a node in a given direction. |
java.lang.Object |
set(long lIndex, java.lang.Object oValue)Add the passed item to the LongArray at the specified index. |
void |
validate()Validate that the tree is a proper AVL tree. |
| Methods inherited from class com.tangosol.util.AbstractLongArray |
|---|
add, contains, equals, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, toString |
| Field Detail |
|---|
protected AbstractSparseArray.Node m_head
protected int m_size
| Constructor Detail |
|---|
public AbstractSparseArray()
| Method Detail |
|---|
public java.lang.Object get(long lIndex)
get in interface LongArrayget in class AbstractLongArraylIndex - a long index value
public java.lang.Object set(long lIndex,
java.lang.Object oValue)
If the index is already used, the passed value will replace the current value stored with the key, and the replaced value will be returned.
It is expected that LongArray implementations will "grow" as necessary to support the specified index.
lIndex - a long index valueoValue - the object to store at the specified indexpublic boolean exists(long lIndex)
exists in interface LongArrayexists in class AbstractLongArraylIndex - a long index valuepublic java.lang.Object remove(long lIndex)
remove in interface LongArrayremove in class AbstractLongArraylIndex - the index into the LongArraypublic void clear()
clear in interface LongArrayclear in class AbstractLongArraypublic int getSize()
getSize in interface LongArraygetSize in class AbstractLongArraypublic LongArray.Iterator iterator()
public LongArray.Iterator iterator(long lIndex)
lIndex - the LongArray index to iterate frompublic LongArray.Iterator reverseIterator()
public LongArray.Iterator reverseIterator(long lIndex)
lIndex - the LongArray index to iterate frompublic long getFirstIndex()
getFirstIndex in interface LongArraygetFirstIndex in class AbstractLongArraypublic long getLastIndex()
getLastIndex in interface LongArraygetLastIndex in class AbstractLongArraypublic java.lang.Object clone()
clone in interface LongArrayclone in class AbstractLongArraypublic void print()
public void validate()
protected AbstractSparseArray.Node find(long lIndex)
lIndex - the long index to look for in the SparseArrayprotected void remove(AbstractSparseArray.Node node)
The supplied node must be part of the tree.
node - the node to remove
protected AbstractSparseArray.Node replace(AbstractSparseArray.Node nodeA,
AbstractSparseArray.Node nodeB)
nodeA - the node to be unlinkednodeB - the node to be linked in nodeA's place; may be null
protected AbstractSparseArray.Node rotate(AbstractSparseArray.Node node,
boolean fLeft)
node - the node to rotatefLeft - the rotation direction
protected AbstractSparseArray.Node doubleRotate(AbstractSparseArray.Node node,
boolean fLeft)
node - the node to rotatefLeft - the final rotation direction
protected void adjustDoubleBalance(AbstractSparseArray.Node node,
AbstractSparseArray.Node child,
int iBal)
node - the node which was rotatedchild - the child to adjustiBal - the balance adjustmentprotected AbstractSparseArray.Node findInsertionPoint(long lIndex)
If the tree is empty then null is returned. If the index already exists then the existing Node is returned, otherwise the Node which will be the parent of the new Node is returned.
lIndex - the index of the new node
protected void balancedInsertion(AbstractSparseArray.Node parent,
AbstractSparseArray.Node child)
parent - the location at which to insert the nodechild - the node to insert
protected void balancePostRemove(AbstractSparseArray.Node pruned,
boolean fPrunedLeft)
pruned - the node whose sub-tree shurnkfPrunedLeft - the side on which the sub-tree shurnk
protected abstract AbstractSparseArray.Node instantiateNode(long lKey,
java.lang.Object oValue)
lKey - the long keyoValue - the object value
protected AbstractSparseArray.Crawler instantiateCrawler(AbstractSparseArray.Node head,
int fromdir,
boolean fForward)
head - the node at which to start the crawlfromdir - the direction in which to start the crawl
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||