IntArray
public class IndexArray extends java.lang.Object implements IntArray
Class IndexArray
stores an array whose entries
are elements of a bounded set of non-negative integers along with an upper
bound. Both the stored array and upper bound are specified at the time of
object construction. It is the client code that constructs a
IndexArray
object's responsibility to ensure that the bound
specified at construction is correct. The contract for this class
is undefined if the bound is specified at object construction is incorrect.
It is recommended that the bound be the minimum integer that is greater
than all elements in the stored array, but not is not a requirement.
Instances of class IndexArray
are immutable.
Constructor | Description |
---|---|
IndexArray(IntArray intArray,
int valueSize) |
Constructs a new
IndexArray instance from the specified
data. |
Modifier and Type | Method | Description |
---|---|---|
int |
get(int index) |
Returns the specified array element.
|
IntArray |
intArray() |
Returns the wrapped
IntArray object. |
int |
size() |
Returns the number of elements in this
IntArray . |
int |
valueSize() |
Returns the value size that was specified at construction.
|
static int |
valueSize(int[] ia) |
Returns the minimum integer that is greater than all elements in the
specified array of non-negative values.
|
static int |
valueSize(IntArray ia) |
Returns the minimum integer that is greater than all elements in the
specified list of non-negative values.
|
public IndexArray(IntArray intArray, int valueSize)
IndexArray
instance from the specified
data. The contract for this constructor and class is unspecified if
the sequence indices are not a subset of
0, 1, ..., (valueSize - 1)
.intArray
- an array with non-negative valuesvalueSize
- a value that is greater than all elements
of the specified arrayjava.lang.NullPointerException
- if IndexArray == null
public int get(int index)
IntArray
public int size()
IntArray
IntArray
.public int valueSize()
public IntArray intArray()
IntArray
object.IntArray
objectpublic static int valueSize(int[] ia)
ia
- an array of non-negative valuesjava.lang.IllegalArgumentException
- if any element of the specified array is
negativepublic static int valueSize(IntArray ia)
ia
- an array of non-negative valuesjava.lang.IllegalArgumentException
- if any element of the specified array
is negative