public class PrimitiveSparseArray extends AbstractSparseArray<Long> implements LongArray<Long>
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.
SparseArray
Modifier and Type | Class and Description |
---|---|
class |
PrimitiveSparseArray.Iterator
Iterator over long values stored in the tree.
|
protected static class |
PrimitiveSparseArray.PrimitiveNode
Node mapping long key to Object value.
|
AbstractSparseArray.Crawler, AbstractSparseArray.Node<V>
m_head, m_size
Constructor and Description |
---|
PrimitiveSparseArray()
Default constructor.
|
PrimitiveSparseArray(PrimitiveSparseArray array)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
getPrimitive(long lIndex)
Return the value stored at the specified index.
|
protected AbstractSparseArray.Crawler |
instantiateCrawler(AbstractSparseArray.Node head,
int fromdir,
boolean fForward)
Instantiate a new Crawler at the specified location and direction.
|
protected AbstractSparseArray.Node |
instantiateNode(long lKey,
long lValue)
Create a new Node with the specified key and value.
|
protected AbstractSparseArray.Node |
instantiateNode(long lKey,
Long value)
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. |
long |
removePrimitive(long lIndex)
Remove the specified index from the PrimitiveSparseArray, returning its
associated value.
|
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. |
long |
setPrimitive(long lIndex,
long lValue)
Add the passed item to the PrimitiveSparseArray at the specified index.
|
adjustDoubleBalance, balancedInsertion, balancePostRemove, ceiling, ceilingIndex, clear, clone, doubleRotate, exists, find, findInsertionPoint, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, print, remove, remove, remove, replace, rotate, set, validate
add, contains, equals, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
add, ceiling, ceilingIndex, clear, clone, contains, equals, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, keys, lastIndexOf, lastIndexOf, remove, remove, set, toString
forEach, spliterator
public PrimitiveSparseArray()
public PrimitiveSparseArray(PrimitiveSparseArray array)
array
- a PrimitiveSparseArray to copy from.public LongArray.Iterator iterator()
public LongArray.Iterator iterator(long lIndex)
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.public LongArray.Iterator reverseIterator()
reverseIterator
in interface LongArray<Long>
reverseIterator
in class AbstractSparseArray<Long>
public LongArray.Iterator reverseIterator(long lIndex)
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.reverseIterator
in interface LongArray<Long>
reverseIterator
in class AbstractSparseArray<Long>
lIndex
- the LongArray index to iterate frompublic long getPrimitive(long lIndex)
lIndex
- a long index valuepublic long removePrimitive(long lIndex)
lIndex
- the index into the LongArraypublic long setPrimitive(long lIndex, long lValue)
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 valuelValue
- the long value to store at the specified indexprotected AbstractSparseArray.Node instantiateNode(long lKey, Long value)
instantiateNode
in class AbstractSparseArray<Long>
lKey
- the long keyvalue
- the object valueprotected AbstractSparseArray.Node instantiateNode(long lKey, long lValue)
lKey
- the long keylValue
- the long valueprotected AbstractSparseArray.Crawler instantiateCrawler(AbstractSparseArray.Node head, int fromdir, boolean fForward)
instantiateCrawler
in class AbstractSparseArray<Long>
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