Oracle® Coherence Java API Reference
v3.5

E14977-01

com.tangosol.util
Class SimpleLongArray

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

public class SimpleLongArray
extends AbstractLongArray
implements java.io.Serializable

An implementation of LongArray that stores values in an array, thus is actually an "IntArray". Optimized for 0-based arrays. Null values are not considered to be entries, thus will not affect "first" and "last" and will not show up in the iterator. Note: not designed to be thread safe.

Version:
1.00 2003.04.09
Author:
cp

Nested Class Summary
 class SimpleLongArray.Iterator
          An Iterator that adds a "current element" concept, similar to the Map.Entry interface.
 
Field Summary
static java.lang.Object[] EMPTY
          Empty array of objects.
static long MAX
          Maximum index value.
 
Fields inherited from interface com.tangosol.util.LongArray
NOT_FOUND
 
Constructor Summary
SimpleLongArray()
          Construct an empty SimpleLongArray.
 
Method Summary
 long add(java.lang.Object oValue)
          Add the passed element value to the LongArray and return the index at which the element value was stored.
 void clear()
          Remove all nodes from the LongArray.
 java.lang.Object clone()
          Make a clone of the LongArray.
 boolean contains(java.lang.Object oValue)
          Determine if the LongArray contains the specified element.
 boolean exists(long lIndex)
          Determine if the specified index is in use.
 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.
 long indexOf(java.lang.Object oValue, long lIndex)
          Return the index in this LongArray of the first occurrence of the specified element such that (index >= lIndex), or NOT_FOUND if this LongArray does not contain the specified element.
 boolean isEmpty()
          Test for empty LongArray.
 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 lastIndexOf(java.lang.Object oValue, long lIndex)
          Return the index in this LongArray of the last occurrence of the specified element such that (index <= lIndex), or NOT_FOUND if this LongArray does not contain the specified element.
 java.lang.Object remove(long lIndex)
          Remove the specified index from the LongArray, 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.
 java.lang.Object set(long lIndex, java.lang.Object oValue)
          Add the passed item to the LongArray at the specified index.
 
Methods inherited from class com.tangosol.util.AbstractLongArray
equals, indexOf, lastIndexOf, toString
 

Field Detail

MAX

public static final long MAX
Maximum index value.

See Also:
Constant Field Values

EMPTY

public static final java.lang.Object[] EMPTY
Empty array of objects.

Constructor Detail

SimpleLongArray

public SimpleLongArray()
Construct an empty SimpleLongArray.

Method Detail

get

public java.lang.Object get(long lIndex)
Return the value stored at the specified index.

Specified by:
get in interface LongArray
Overrides:
get in class AbstractLongArray
Parameters:
lIndex - a long index value
Returns:
the object stored at the specified index, or null

set

public java.lang.Object set(long lIndex,
                            java.lang.Object oValue)
Add the passed item to the LongArray 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.

Specified by:
set in interface LongArray
Parameters:
lIndex - a long index value
oValue - the object to store at the specified index
Returns:
the object that was stored at the specified index, or null

add

public long add(java.lang.Object oValue)
Add the passed element value to the LongArray and return the index at which the element value was stored.

Specified by:
add in interface LongArray
Overrides:
add in class AbstractLongArray
Parameters:
oValue - the object to add to the LongArray
Returns:
the long index value at which the element value was stored

exists

public boolean exists(long lIndex)
Determine if the specified index is in use.

Specified by:
exists in interface LongArray
Overrides:
exists in class AbstractLongArray
Parameters:
lIndex - a long index value
Returns:
true if a value (including null) is stored at the specified index, otherwise false

remove

public java.lang.Object remove(long lIndex)
Remove the specified index from the LongArray, returning its associated value.

Specified by:
remove in interface LongArray
Overrides:
remove in class AbstractLongArray
Parameters:
lIndex - the index into the LongArray
Returns:
the associated value (which can be null) or null if the specified index is not in the LongArray

contains

public boolean contains(java.lang.Object oValue)
Determine if the LongArray contains the specified element.

More formally, returns true if and only if this LongArray contains at least one element e such that (oValue==null ? e==null : oValue.equals(e)).

Specified by:
contains in interface LongArray
Overrides:
contains in class AbstractLongArray
Parameters:
oValue - element whose presence in this list is to be tested
Returns:
true if this list contains the specified element

clear

public void clear()
Remove all nodes from the LongArray.

Specified by:
clear in interface LongArray
Overrides:
clear in class AbstractLongArray

isEmpty

public boolean isEmpty()
Test for empty LongArray.

Specified by:
isEmpty in interface LongArray
Overrides:
isEmpty in class AbstractLongArray
Returns:
true if LongArray has no nodes

getSize

public int getSize()
Determine the size of the LongArray.

Specified by:
getSize in interface LongArray
Overrides:
getSize in class AbstractLongArray
Returns:
the number of nodes in the LongArray

iterator

public LongArray.Iterator iterator()
Obtain a LongArray.Iterator of the contents of the LongArray.

Specified by:
iterator in interface LongArray
Returns:
an instance of LongArray.Iterator

iterator

public 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.

Specified by:
iterator in interface LongArray
Parameters:
lIndex - the LongArray index to iterate from
Returns:
an instance of LongArray.Iterator

reverseIterator

public LongArray.Iterator reverseIterator()
Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices).

Specified by:
reverseIterator in interface LongArray
Returns:
an instance of LongArray.Iterator

reverseIterator

public 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.

Specified by:
reverseIterator in interface LongArray
Parameters:
lIndex - the LongArray index to iterate from
Returns:
an instance of LongArray.Iterator

getFirstIndex

public long getFirstIndex()
Determine the first index that exists in the LongArray.

Specified by:
getFirstIndex in interface LongArray
Overrides:
getFirstIndex in class AbstractLongArray
Returns:
the lowest long value that exists in this LongArray, or NOT_FOUND if the LongArray is empty

getLastIndex

public long getLastIndex()
Determine the last index that exists in the LongArray.

Specified by:
getLastIndex in interface LongArray
Overrides:
getLastIndex in class AbstractLongArray
Returns:
the highest long value that exists in this LongArray, or NOT_FOUND if the LongArray is empty

indexOf

public long indexOf(java.lang.Object oValue,
                    long lIndex)
Return the index in this LongArray of the first occurrence of the specified element such that (index >= lIndex), or NOT_FOUND if this LongArray does not contain the specified element.

Specified by:
indexOf in interface LongArray
Overrides:
indexOf in class AbstractLongArray

lastIndexOf

public long lastIndexOf(java.lang.Object oValue,
                        long lIndex)
Return the index in this LongArray of the last occurrence of the specified element such that (index <= lIndex), or NOT_FOUND if this LongArray does not contain the specified element.

Specified by:
lastIndexOf in interface LongArray
Overrides:
lastIndexOf in class AbstractLongArray

clone

public java.lang.Object clone()
Make a clone of the LongArray. The element values are not deep-cloned.

Specified by:
clone in interface LongArray
Overrides:
clone in class AbstractLongArray
Returns:
a clone of this LongArray object

Oracle® Coherence Java API Reference
v3.5

E14977-01

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