public final class IndexCollection extends AbstractList<IndexValue> implements List<IndexValue>, Externalizable
A List
of IndexValue
s which may be used to query the StateServer object
store for the set of objects with metadata matching the (positional) values specified in the
IndexCollection
.
IndexCollection
s are fixed-length List
s where the length is defined by
the StateServer implementation. Not all index positions need have values. That is, an
IndexCollection
may be sparsely filled in.
Since the index position of an item in an IndexCollection
is semantically key, this
List
implementation does not support List.add(E)
or List.remove(java.lang.Object)
operations. It does support List.clear()
by resetting the value in all index
positions to null
. Similarly, it supports selective clearing via
clearRange(int, int)
.
Modifier and Type | Field and Description |
---|---|
static int |
MaxIndexValues
The fixed number of
IndexValue s an IndexCollection may hold. |
Constructor and Description |
---|
IndexCollection() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(IndexValue o)
Adding to the end of an
IndexCollection is not supported. |
void |
add(int index,
IndexValue element)
Inserts the specified
IndexValue at the specified position in this list. |
void |
clear()
Clears all elements in the
IndexCollection by setting the IndexValue in
each index position to null . |
void |
clearRange(int fromIndex,
int toIndex)
Clears a range of elements in the
IndexCollection by setting the
IndexValue s in the corresponding index positions to null . |
IndexValue |
get(int index)
Gets the element at the specified index.
|
boolean |
isEmpty()
|
void |
readExternal(ObjectInput in) |
IndexValue |
remove(int index)
Removes the element at the specified index of the
IndexCollection . |
IndexValue |
set(int index,
IndexValue element)
Replaces the element at the specified position in this list with the specified element
(optional operation).
|
int |
size()
Gets the number of elements in the
IndexCollection . |
void |
writeExternal(ObjectOutput out) |
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
addAll, addAll, contains, containsAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public static final int MaxIndexValues
IndexValue
s an IndexCollection
may hold. This value
is currently 8.public IndexValue get(int index)
If no element has been assigned to a given index position, the get operation will return
null
.
get
in interface List<IndexValue>
get
in class AbstractList<IndexValue>
index
- The index of the element to get or set.null
if no element has
been assigned to the given index position.IndexOutOfBoundsException
- if the index is out of range (index < 0 or index >= size()
).public IndexValue set(int index, IndexValue element)
set
in interface List<IndexValue>
set
in class AbstractList<IndexValue>
index
- the index of element to replace.element
- the IndexValue
to be stored at the specified position.IndexValue
previously at the specified position.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public int size()
IndexCollection
. Since the collection is
fixed-size, this method always returns MaxIndexValues
.size
in interface Collection<IndexValue>
size
in interface List<IndexValue>
size
in class AbstractCollection<IndexValue>
MaxIndexValues
public void clear()
IndexCollection
by setting the IndexValue
in
each index position to null
.clear
in interface Collection<IndexValue>
clear
in interface List<IndexValue>
clear
in class AbstractList<IndexValue>
public void clearRange(int fromIndex, int toIndex)
Clears a range of elements in the IndexCollection
by setting the
IndexValue
s in the corresponding index positions to null
.
fromIndex
, inclusive, to index
toIndex
, exclusive. (If fromIndex==toIndex
, the range to be
cleared is empty.)fromIndex
- the index of the first element (inclusive) to be cleared.toIndex
- the index of the last element (exclusive) to be cleared.IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > size()
public boolean isEmpty()
isEmpty
in interface Collection<IndexValue>
isEmpty
in interface List<IndexValue>
isEmpty
in class AbstractCollection<IndexValue>
true
if this IndexCollection
contains no (non-null
)
IndexValue
s. Otherwise, false
.public IndexValue remove(int index)
IndexCollection
. All
elements in the list following the removed element are moved 1 position to the left. The
element at MaxIndexValues
- 1
is set to null
.remove
in interface List<IndexValue>
remove
in class AbstractList<IndexValue>
index
- The zero-based index of the element to remove.public void add(int index, IndexValue element) throws IndexOutOfBoundsException
Inserts the specified IndexValue
at the specified position in this list. Shifts
the element currently at that position and any subsequent elements to the right (adds
one to their indices). The element at position
is removed from the collection.
MaxIndexValues
-1
IndexCollection
s are fixed-length List
s, index must be
less than size()
.add
in interface List<IndexValue>
add
in class AbstractList<IndexValue>
index
- index at which the specified element is to be inserted.element
- the IndexValue
to be inserted.IndexOutOfBoundsException
- index is out of range (index <
0 || index >= size()
).public boolean add(IndexValue o)
IndexCollection
is not supported.add
in interface Collection<IndexValue>
add
in interface List<IndexValue>
add
in class AbstractList<IndexValue>
UnsupportedOperationException
- when adding to the end of the IndexCollection
add(int, IndexValue)
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
Copyright (C) 2007-2014 ScaleOut Software, Inc.