Oracle® Coherence Java API Reference
v3.5

E14977-01

com.tangosol.util
Class PrimitiveSparseArray

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractLongArray
          extended by com.tangosol.util.AbstractSparseArray
              extended by com.tangosol.util.PrimitiveSparseArray
All Implemented Interfaces:
LongArray, java.io.Serializable, java.lang.Cloneable

public class PrimitiveSparseArray
extends AbstractSparseArray

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:
SparseArray

Nested Class Summary
 class PrimitiveSparseArray.Iterator
          Iterator over long values stored in the tree.
protected static class PrimitiveSparseArray.PrimitiveNode
          Node mapping long key to Object value.
 
Nested classes/interfaces inherited from class com.tangosol.util.AbstractSparseArray
AbstractSparseArray.Crawler, AbstractSparseArray.Node
 
Field Summary
 
Fields inherited from class com.tangosol.util.AbstractSparseArray
m_head, m_size
 
Fields inherited from interface com.tangosol.util.LongArray
NOT_FOUND
 
Constructor Summary
PrimitiveSparseArray()
          Default constructor.
 
Method Summary
 long getPrimitive(long lIndex)
          Return the value stored at the specified index.
protected  AbstractSparseArray.Crawler instantiateCrawler(AbstractSparseArray.Node head, int fromdir, boolean fForward)
          Instantate 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, java.lang.Object oValue)
          Factory pattern: create a new Node with the specified key and value.
 long removePrimitive(long lIndex)
          Remove the specified index from the PrimitiveSparseArray, returning its associated value.
 long setPrimitive(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, clear, clone, doubleRotate, exists, find, findInsertionPoint, get, getFirstIndex, getLastIndex, getSize, iterator, iterator, print, remove, remove, replace, reverseIterator, reverseIterator, rotate, set, validate
 
Methods inherited from class com.tangosol.util.AbstractLongArray
add, contains, equals, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, toString
 

Constructor Detail

PrimitiveSparseArray

public PrimitiveSparseArray()
Default constructor.

Method Detail

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 value
lValue - 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

protected AbstractSparseArray.Node instantiateNode(long lKey,
                                                   java.lang.Object oValue)
Description copied from class: AbstractSparseArray
Factory pattern: create a new Node with the specified key and value.

Specified by:
instantiateNode in class AbstractSparseArray
Parameters:
lKey - the long key
oValue - the object value
Returns:
the new node

instantiateNode

protected AbstractSparseArray.Node instantiateNode(long lKey,
                                                   long lValue)
Create a new Node with the specified key and value.

Parameters:
lKey - the long key
lValue - the long value
Returns:
the new node

instantiateCrawler

protected AbstractSparseArray.Crawler instantiateCrawler(AbstractSparseArray.Node head,
                                                         int fromdir,
                                                         boolean fForward)
Description copied from class: AbstractSparseArray
Instantate a new Crawler at the specified location and direction.

Overrides:
instantiateCrawler in class AbstractSparseArray
Parameters:
head - the node at which to start the crawl
fromdir - the direction in which to start the crawl
Returns:
the new crawler

Oracle® Coherence Java API Reference
v3.5

E14977-01

Copyright © 2000, 2009, Oracle. All rights reserved.