Package com.tangosol.util
Class SimpleLongArray
java.lang.Object
com.tangosol.util.AbstractLongArray
com.tangosol.util.SimpleLongArray
- All Implemented Interfaces:
LongArray,Serializable,Cloneable,Iterable
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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn Iterator that adds a "current element" concept, similar to theMap.Entryinterface. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object[]Empty array of objects.static final longMaximum index value. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty SimpleLongArray.SimpleLongArray(Object oValue) Create aSimpleLongArraywith a single entry at index zero. -
Method Summary
Modifier and TypeMethodDescriptionlongAdd the passed element value to the LongArray and return the index at which the element value was stored.ceiling(long lIndex) Return the "first" value with an index which is greater than or equal to the specified index.longceilingIndex(long lIndex) Return the "first" index which is greater than or equal to the specified index.voidclear()Remove all nodes from the LongArray.clone()Make a clone of the LongArray.booleanDetermine if the LongArray contains the specified element.booleanexists(long lIndex) Determine if the specified index is in use.floor(long lIndex) Return the "first" value with an index which is less than or equal to the specified index.longfloorIndex(long lIndex) Return the "first" index which is less than or equal to the specified index.get(long lIndex) Return the value stored at the specified index.longDetermine the first index that exists in the LongArray.longDetermine the last index that exists in the LongArray.intgetSize()Determine the size of the LongArray.longReturn 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.booleanisEmpty()Test for empty LongArray.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.longlastIndexOf(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.remove(long lIndex) Remove the specified index from the LongArray, 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.Add the passed item to the LongArray at the specified index.Methods inherited from class com.tangosol.util.AbstractLongArray
equals, hashCode, indexOf, lastIndexOf, remove, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MAX
public static final long MAXMaximum index value.- See Also:
-
EMPTY
Empty array of objects.
-
-
Constructor Details
-
SimpleLongArray
public SimpleLongArray()Construct an empty SimpleLongArray. -
SimpleLongArray
Create aSimpleLongArraywith a single entry at index zero.- Parameters:
oValue- the value to add at index zero- Throws:
NullPointerException- if the value isnull
-
-
Method Details
-
get
Return the value stored at the specified index.- Specified by:
getin interfaceLongArray- Overrides:
getin classAbstractLongArray- Parameters:
lIndex- a long index value- Returns:
- the object stored at the specified index, or null
-
floorIndex
public long floorIndex(long lIndex) Description copied from interface:LongArrayReturn the "first" index which is less than or equal to the specified index.- Specified by:
floorIndexin interfaceLongArray- Parameters:
lIndex- the index- Returns:
- the index or NOT_FOUND
-
floor
Description copied from interface:LongArrayReturn the "first" value with an index which is less than or equal to the specified index. -
ceilingIndex
public long ceilingIndex(long lIndex) Description copied from interface:LongArrayReturn the "first" index which is greater than or equal to the specified index.- Specified by:
ceilingIndexin interfaceLongArray- Parameters:
lIndex- the index- Returns:
- the index or NOT_FOUND
-
ceiling
Description copied from interface:LongArrayReturn the "first" value with an index which is greater than or equal to the specified index. -
set
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.
-
add
Add the passed element value to the LongArray and return the index at which the element value was stored.- Specified by:
addin interfaceLongArray- Overrides:
addin classAbstractLongArray- 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:
existsin interfaceLongArray- Overrides:
existsin classAbstractLongArray- Parameters:
lIndex- a long index value- Returns:
- true if a value (including null) is stored at the specified index, otherwise false
-
remove
Remove the specified index from the LongArray, returning its associated value.- Specified by:
removein interfaceLongArray- Overrides:
removein classAbstractLongArray- 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
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:
containsin interfaceLongArray- Overrides:
containsin classAbstractLongArray- 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:
clearin interfaceLongArray- Overrides:
clearin classAbstractLongArray
-
isEmpty
public boolean isEmpty()Test for empty LongArray.- Specified by:
isEmptyin interfaceLongArray- Overrides:
isEmptyin classAbstractLongArray- Returns:
- true if LongArray has no nodes
-
getSize
public int getSize()Determine the size of the LongArray.- Specified by:
getSizein interfaceLongArray- Overrides:
getSizein classAbstractLongArray- Returns:
- the number of nodes in the LongArray
-
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- 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- 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:
getFirstIndexin interfaceLongArray- Overrides:
getFirstIndexin classAbstractLongArray- 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:
getLastIndexin interfaceLongArray- Overrides:
getLastIndexin classAbstractLongArray- Returns:
- the highest long value that exists in this LongArray, or NOT_FOUND if the LongArray is empty
-
indexOf
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:
indexOfin interfaceLongArray- Overrides:
indexOfin classAbstractLongArray- Parameters:
oValue- the object to find the index forlIndex- the index to compare to- Returns:
- the index of the specified object in the LongArray that is greater or equal to the specified index
-
lastIndexOf
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:
lastIndexOfin interfaceLongArray- Overrides:
lastIndexOfin classAbstractLongArray- Parameters:
oValue- the object to find the index forlIndex- the index to compare to- Returns:
- the index of the specified object in this LongArray that is less or equal to the specified index
-
clone
Make a clone of the LongArray. The element values are not deep-cloned.- Specified by:
clonein interfaceLongArray- Overrides:
clonein classAbstractLongArray- Returns:
- a clone of this LongArray object
-