Package ints
Class PackedIntArray
- java.lang.Object
-
- ints.PackedIntArray
-
-
Constructor Summary
Constructors Constructor Description PackedIntArray(int[] ia, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.PackedIntArray(IntList il, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PackedIntArrayfromSignedByteArray(byte[] ba, int valueSize)Constructs and returns a newPackedIntArrayinstance from the specified data.static PackedIntArrayfromSignedByteArray(byte[] ba, int from, int to, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.static PackedIntArrayfromUnsignedByteArray(byte[] ba, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.static PackedIntArrayfromUnsignedByteArray(byte[] ba, int from, int to, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.static PackedIntArrayfromUnsignedTwoByteArray(byte[] ba, int valueSize)Constructs a newPackedIntArrayinstance from the specified data.intget(int index)Returns the specified array element.intsize()Returns the number of elements in thisIntArray.
-
-
-
Constructor Detail
-
PackedIntArray
public PackedIntArray(int[] ia, int valueSize)Constructs a newPackedIntArrayinstance 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 < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)java.lang.NullPointerException- ifia == null
-
PackedIntArray
public PackedIntArray(IntList il, int valueSize)
Constructs a newPackedIntArrayinstance 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 < 1java.lang.IllegalArgumentException- if(il.get(j) < 0 || il.get(j) > valueSize)for any indexjsatisfying(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 newPackedIntArrayinstance 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
PackedIntArrayinstance - Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(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 newPackedIntArrayinstance 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
PackedIntArrayinstance - Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)java.lang.IndexOutOfBoundsException- iffrom < 0 || to > ia.lengthjava.lang.NegativeArraySizeException- ifto > fromjava.lang.NullPointerException- ifia == null
-
fromUnsignedByteArray
public static PackedIntArray fromUnsignedByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArrayinstance 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
PackedIntArrayinstance - Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(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 newPackedIntArrayinstance 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
PackedIntArrayinstance - Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)java.lang.IndexOutOfBoundsException- iffrom < 0 || to > ia.lengthjava.lang.NegativeArraySizeException- ifto > fromjava.lang.NullPointerException- ifia == null
-
fromUnsignedTwoByteArray
public static PackedIntArray fromUnsignedTwoByteArray(byte[] ba, int valueSize)
Constructs a newPackedIntArrayinstance from the specified data. The specified array representsba.length/2unsigned two-byte values. Thej-th unsigned two-byte value is stored in array elements2*jand(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
PackedIntArrayinstance - Throws:
java.lang.IllegalArgumentException- ifvalueSize < 1java.lang.IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)java.lang.IllegalArgumentException- if(ba.length & 1) != 0java.lang.NullPointerException- ifia == null
-
size
public int size()
Description copied from interface:IntArrayReturns the number of elements in thisIntArray.
-
-