Package com.tangosol.util
Interface LongArray<V>
- All Superinterfaces:
Cloneable
,Iterable<V>
,Serializable
- All Known Implementing Classes:
AbstractLongArray
,AbstractSafeLongArray
,AbstractSparseArray
,ConverterCollections.ConverterLongArray
,CopyOnWriteLongArray
,NullImplementation.NullLongArray
,PrimitiveSparseArray
,ReadHeavyLongArray
,SafeLongArray
,SimpleLongArray
,SparseArray
,WrapperCollections.AbstractWrapperLongArray
An interface, similar in its methods to List, and similar in its purpose
to a Java array, designed for sparse storage and indexed by long values.
Unlike the List interface, the LongArray interface assumes that every index can be accessed and has storage available.
- Version:
- 1.00 2002.04.24 based on WindowedArray component and SparseArray prototype
- Author:
- cp
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An Iterator that adds a "current element" concept, similar to theMap.Entry
interface. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
This index is used to indicate that an element was not found. -
Method Summary
Modifier and TypeMethodDescriptionlong
Add 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.long
ceilingIndex
(long lIndex) Return the "first" index which is greater than or equal to the specified index.void
clear()
Remove all nodes from the LongArray.clone()
Make a clone of the LongArray.boolean
Determine if the LongArray contains the specified element.boolean
Test for LongArray equality.boolean
exists
(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.long
floorIndex
(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.long
Determine the first index that exists in the LongArray.long
Determine the last index that exists in the LongArray.int
getSize()
Determine the size of the LongArray.long
Return the index in this LongArray of the first occurrence of the specified element, or NOT_FOUND if this LongArray does not contain the specified element.long
Return the index in this LongArray of the first occurrence of the specified element such that (index greater or equal to lIndex), or NOT_FOUND if this LongArray does not contain the specified element.boolean
isEmpty()
Test for empty LongArray.iterator()
Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing indices.iterator
(long lIndex) Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing 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 greater than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index.default long[]
keys()
Return an array of the indices into this LongArray.long
lastIndexOf
(V oValue) Return the index in this LongArray of the last occurrence of the specified element, or NOT_FOUND if this LongArray does not contain the specified element.long
lastIndexOf
(V oValue, long lIndex) Return the index in this LongArray of the last occurrence of the specified element such that (index less then or equal to 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.void
remove
(long lIndexFrom, long lIndexTo) Remove all nodes in the specified range.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.static <V> LongArray
<V> singleton
(V oValue) toString()
Provide a string representation of the LongArray.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NOT_FOUND
static final long NOT_FOUNDThis index is used to indicate that an element was not found.- See Also:
-
-
Method Details
-
get
Return the value stored at the specified index.- Parameters:
lIndex
- a long index value- Returns:
- the object stored at the specified index, or null
-
floorIndex
long floorIndex(long lIndex) Return the "first" index which is less than or equal to the specified index.- Parameters:
lIndex
- the index- Returns:
- the index or NOT_FOUND
-
floor
Return the "first" value with an index which is less than or equal to the specified index.- Parameters:
lIndex
- the index- Returns:
- the value or null
-
ceilingIndex
long ceilingIndex(long lIndex) Return the "first" index which is greater than or equal to the specified index.- Parameters:
lIndex
- the index- Returns:
- the index or NOT_FOUND
-
ceiling
Return the "first" value with an index which is greater than or equal to the specified index.- Parameters:
lIndex
- the index- Returns:
- the value or null
-
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.
- Parameters:
lIndex
- a long index valueoValue
- the object to store at the specified index- Returns:
- the object that was stored at the specified index, or null
-
add
Add the passed element value to the LongArray and return the index at which the element value was stored.- Parameters:
oValue
- the object to add to the LongArray- Returns:
- the long index value at which the element value was stored
-
exists
boolean exists(long lIndex) Determine if the specified index is in use.- 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.- 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
-
remove
void remove(long lIndexFrom, long lIndexTo) Remove all nodes in the specified range.- Parameters:
lIndexFrom
- the floor indexlIndexTo
- the ceiling index (exclusive)
-
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 (o==null ? e==null : o.equals(e)).
- Parameters:
oValue
- element whose presence in this list is to be tested- Returns:
- true if this list contains the specified element
-
clear
void clear()Remove all nodes from the LongArray. -
isEmpty
boolean isEmpty()Test for empty LongArray.- Returns:
- true if LongArray has no nodes
-
getSize
int getSize()Determine the size of the LongArray.- Returns:
- the number of nodes in the LongArray
-
iterator
LongArray.Iterator<V> iterator()Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing indices. -
iterator
Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing 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 greater than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index.- Parameters:
lIndex
- the LongArray index to iterate from- Returns:
- an instance of LongArray.Iterator
-
reverseIterator
LongArray.Iterator<V> reverseIterator()Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices).- 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.- Parameters:
lIndex
- the LongArray index to iterate from- Returns:
- an instance of LongArray.Iterator
-
getFirstIndex
long getFirstIndex()Determine the first index that exists in the LongArray.- Returns:
- the lowest long value that exists in this LongArray, or NOT_FOUND if the LongArray is empty
-
getLastIndex
long getLastIndex()Determine the last index that exists in the LongArray.- 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, or NOT_FOUND if this LongArray does not contain the specified element.- Parameters:
oValue
- the object to find index for- Returns:
- the index of the specified object in the LongArray
-
indexOf
Return the index in this LongArray of the first occurrence of the specified element such that (index greater or equal to lIndex), or NOT_FOUND if this LongArray does not contain the specified element.- 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, or NOT_FOUND if this LongArray does not contain the specified element.- Parameters:
oValue
- the object to find the index for- Returns:
- the index of the last occurrence of the specified object in the LongArray
-
lastIndexOf
Return the index in this LongArray of the last occurrence of the specified element such that (index less then or equal to lIndex), or NOT_FOUND if this LongArray does not contain the specified element.- 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
-
keys
default long[] keys()Return an array of the indices into this LongArray.- Returns:
- an array of the indices into this LongArray
- Since:
- 12.2.1.4
-
toString
String toString()Provide a string representation of the LongArray. -
equals
Test for LongArray equality. -
clone
Make a clone of the LongArray. The element values are not deep-cloned.- Returns:
- a clone of this LongArray object
-
singleton
-