Package com.tangosol.util
Class PrimitiveSparseArray
A data structure resembling a long array indexed by long values.
 
While the PrimitiveSparseArray implements the LongArray interface, it stores all values as primitive longs, and as such any Object supplied to its LongArray interface must be provided as a java.lang.Long. The PrimitiveSparseArray provides additional methods whose signatures utilize primitive longs to avoid the creation of temporary Long objects.
- Author:
 - mf 10.08.2007
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassIterator over long values stored in the tree.protected static classNode mapping long key to Object value.Nested classes/interfaces inherited from class com.tangosol.util.AbstractSparseArray
AbstractSparseArray.Crawler, AbstractSparseArray.Node<V> - 
Field Summary
Fields inherited from class com.tangosol.util.AbstractSparseArray
m_head, m_size - 
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Copy constructor. - 
Method Summary
Modifier and TypeMethodDescriptionlonggetPrimitive(long lIndex) Return the value stored at the specified index.protected AbstractSparseArray<Long>.CrawlerinstantiateCrawler(AbstractSparseArray.Node head, int fromdir, boolean fForward) Instantiate a new Crawler at the specified location and direction.protected AbstractSparseArray.NodeinstantiateNode(long lKey, long lValue) Create a new Node with the specified key and value.protected AbstractSparseArray.NodeinstantiateNode(long lKey, Long value) Factory pattern: create a new Node with the specified key and value.iterator()Obtain a LongArray.Iterator of the contents of the LongArray.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.longremovePrimitive(long lIndex) Remove the specified index from the PrimitiveSparseArray, returning its associated value.Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices).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.longsetPrimitive(long lIndex, long lValue) Add the passed item to the PrimitiveSparseArray at the specified index.Methods inherited from class com.tangosol.util.AbstractSparseArray
adjustDoubleBalance, balancedInsertion, balancePostRemove, ceiling, ceilingIndex, clear, clone, doubleRotate, exists, find, findInsertionPoint, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, print, remove, remove, remove, replace, rotate, set, validateMethods inherited from class com.tangosol.util.AbstractLongArray
add, contains, equals, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.tangosol.util.LongArray
add, ceiling, ceilingIndex, clear, clone, contains, equals, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, keys, lastIndexOf, lastIndexOf, remove, remove, set, toString 
- 
Constructor Details
- 
PrimitiveSparseArray
public PrimitiveSparseArray()Default constructor. - 
PrimitiveSparseArray
Copy constructor.- Parameters:
 array- a PrimitiveSparseArray to copy from.
 
 - 
 - 
Method Details
- 
iterator
Obtain a LongArray.Iterator of the contents of the LongArray. - 
iterator
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. - 
reverseIterator
Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices).- Specified by:
 reverseIteratorin interfaceLongArray<Long>- Overrides:
 reverseIteratorin classAbstractSparseArray<Long>- Returns:
 - an instance of LongArray.Iterator
 
 - 
reverseIterator
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.- Specified by:
 reverseIteratorin interfaceLongArray<Long>- Overrides:
 reverseIteratorin classAbstractSparseArray<Long>- Parameters:
 lIndex- the LongArray index to iterate from- Returns:
 - an instance of LongArray.Iterator
 
 - 
getPrimitive
public long getPrimitive(long lIndex) Return the value stored at the specified index.- Parameters:
 lIndex- a long index value- Returns:
 - the value stored at the specified index, or NOT_FOUND if none exists
 
 - 
removePrimitive
public long removePrimitive(long lIndex) Remove the specified index from the PrimitiveSparseArray, returning its associated value.- Parameters:
 lIndex- the index into the LongArray- Returns:
 - the associated value or NOT_FOUND if the specified index does not exist
 
 - 
setPrimitive
public long setPrimitive(long lIndex, long lValue) Add the passed item to the PrimitiveSparseArray at the specified index.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.
- Parameters:
 lIndex- a long index valuelValue- the long value to store at the specified index- Returns:
 - the value that was stored at the specified index, or NOT_FOUND if the specified index does not exist
 
 - 
instantiateNode
Factory pattern: create a new Node with the specified key and value.- Specified by:
 instantiateNodein classAbstractSparseArray<Long>- Parameters:
 lKey- the long keyvalue- the object value- Returns:
 - the new node
 
 - 
instantiateNode
Create a new Node with the specified key and value.- Parameters:
 lKey- the long keylValue- the long value- Returns:
 - the new node
 
 - 
instantiateCrawler
protected AbstractSparseArray<Long>.Crawler instantiateCrawler(AbstractSparseArray.Node head, int fromdir, boolean fForward) Instantiate a new Crawler at the specified location and direction.- Overrides:
 instantiateCrawlerin classAbstractSparseArray<Long>- Parameters:
 head- the node at which to start crawlingfromdir- the direction in which to start crawlingfForward- true iff crawler should advance forward towards the next element- Returns:
 - the new crawler
 
 
 -