Package ints
Class PackedIntArray
- java.lang.Object
-
- ints.PackedIntArray
-
-
Constructor Summary
Constructors Constructor Description PackedIntArray(int[] ia, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.PackedIntArray(IntList il, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PackedIntArray
fromSignedByteArray(byte[] ba, int valueSize)
Constructs and returns a newPackedIntArray
instance from the specified data.static PackedIntArray
fromSignedByteArray(byte[] ba, int from, int to, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.static PackedIntArray
fromUnsignedByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.static PackedIntArray
fromUnsignedByteArray(byte[] ba, int from, int to, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.static PackedIntArray
fromUnsignedTwoByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.int
get(int index)
Returns the specified array element.int
size()
Returns the number of elements in thisIntArray
.
-
-
-
Constructor Detail
-
PackedIntArray
public PackedIntArray(int[] ia, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.- Parameters:
ia
- an array of nonnegative integer valuesvalueSize
- the exclusive end of the range of non-negative array values- Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifia == null
-
PackedIntArray
public PackedIntArray(IntList il, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.- Parameters:
il
- an array of nonnegative integer valuesvalueSize
- the exclusive end of the range of non-negative array values- Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(il.get(j) < 0 || il.get(j) > valueSize)
for any indexj
satisfying(j >= 0 && j < il.size())
java.lang.NullPointerException
- ifil == null
-
-
Method Detail
-
fromSignedByteArray
public static PackedIntArray fromSignedByteArray(byte[] ba, int valueSize)
Constructs and returns a newPackedIntArray
instance from the specified data.- Parameters:
ba
- an array of non-negative integer valuesvalueSize
- the exclusive end of the range of non-negative array values- Returns:
- a new
PackedIntArray
instance - Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifia == null
-
fromSignedByteArray
public static PackedIntArray fromSignedByteArray(byte[] ba, int from, int to, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.- Parameters:
ba
- an array of non-negative integer valuesfrom
- the first element to be included (inclusive)to
- the last element to be included (exclusive)valueSize
- the exclusive end of the range of non-negative array values- Returns:
- a new
PackedIntArray
instance - Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.IndexOutOfBoundsException
- iffrom < 0 || to > ia.length
java.lang.NegativeArraySizeException
- ifto > from
java.lang.NullPointerException
- ifia == null
-
fromUnsignedByteArray
public static PackedIntArray fromUnsignedByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.- Parameters:
ba
- an array of non-negative integer values represented as unsigned bytesvalueSize
- the exclusive end of the range of non-negative array values- Returns:
- a new
PackedIntArray
instance - Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.NullPointerException
- ifia == null
-
fromUnsignedByteArray
public static PackedIntArray fromUnsignedByteArray(byte[] ba, int from, int to, int valueSize)
Constructs a newPackedIntArray
instance from the specified data.- Parameters:
ba
- an array of non-negative integer values represented as unsigned bytesfrom
- the first element to be included (inclusive)to
- the last element to be included (exclusive)valueSize
- the exclusive end of the range of non-negative array values- Returns:
- a new
PackedIntArray
instance - Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.IndexOutOfBoundsException
- iffrom < 0 || to > ia.length
java.lang.NegativeArraySizeException
- ifto > from
java.lang.NullPointerException
- ifia == null
-
fromUnsignedTwoByteArray
public static PackedIntArray fromUnsignedTwoByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArray
instance from the specified data. The specified array representsba.length/2
unsigned two-byte values. Thej
-th unsigned two-byte value is stored in array elements2*j
and(2*j + 1)
, with the higher-order byte stored in element2*j
.- Parameters:
ba
- an array of non-negative integer values represented as unsigned two-byte integers.valueSize
- the exclusive end of the range of non-negative array values- Returns:
- a new
PackedIntArray
instance - Throws:
java.lang.IllegalArgumentException
- ifvalueSize < 1
java.lang.IllegalArgumentException
- if(ia[j] < 0 || ia[j] > valueSize)
for any indexj
satisfying(j >= 0 && j < ia.length)
java.lang.IllegalArgumentException
- if(ba.length & 1) != 0
java.lang.NullPointerException
- ifia == null
-
size
public int size()
Description copied from interface:IntArray
Returns the number of elements in thisIntArray
.
-
-