Package ints
Class IndexArray
java.lang.Object
ints.IndexArray
- All Implemented Interfaces:
 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 Summary
ConstructorsConstructorDescriptionIndexArray(int[] intArray, int valueSize) Constructs a newIndexArrayinstance from the specified data.IndexArray(IntArray intArray, int valueSize) Constructs a newIndexArrayinstance from the specified data. - 
Method Summary
Modifier and TypeMethodDescriptionintget(int index) Returns the specified array element.intArray()Returns the wrappedIntArrayobject.intsize()Returns the number of elements in thisIntArray.intReturns the value size that was specified at construction.static intvalueSize(int[] ia) Returns the minimum integer that is greater than all elements in the specified array of non-negative values.static intReturns the minimum integer that is greater than all elements in the specified list of non-negative values. 
- 
Constructor Details
- 
IndexArray
public IndexArray(int[] intArray, int valueSize) Constructs a newIndexArrayinstance from the specified data. The contract for this constructor and class is unspecified if the sequence indices are not a subset of0, 1, ..., (valueSize - 1).- Parameters:
 intArray- an array with non-negative valuesvalueSize- a value that is greater than all elements of the specified array- Throws:
 NullPointerException- ifIndexArray == null
 - 
IndexArray
Constructs a newIndexArrayinstance from the specified data. The contract for this constructor and class is unspecified if the sequence indices are not a subset of0, 1, ..., (valueSize - 1).- Parameters:
 intArray- an array with non-negative valuesvalueSize- a value that is greater than all elements of the specified array- Throws:
 NullPointerException- ifIndexArray == null
 
 - 
 - 
Method Details
- 
get
public int get(int index) Description copied from interface:IntArrayReturns the specified array element. - 
size
public int size()Description copied from interface:IntArrayReturns the number of elements in thisIntArray. - 
valueSize
public int valueSize()Returns the value size that was specified at construction.- Returns:
 - the value size that was specified at construction
 
 - 
intArray
Returns the wrappedIntArrayobject.- Returns:
 - the wrapped 
IntArrayobject 
 - 
valueSize
public static int valueSize(int[] ia) Returns the minimum integer that is greater than all elements in the specified array of non-negative values.- Parameters:
 ia- an array of non-negative values- Returns:
 - the minimum integer that is greater than all elements in the specified array of non-negative values
 - Throws:
 IllegalArgumentException- if any element of the specified array is negative
 - 
valueSize
Returns the minimum integer that is greater than all elements in the specified list of non-negative values.- Parameters:
 ia- an array of non-negative values- Returns:
 - the minimum integer that is greater than all elements in the specified array of non-negative values
 - Throws:
 IllegalArgumentException- if any element of the specified array is negative
 
 -