Package ints
Class UnsignedByteArray
java.lang.Object
ints.UnsignedByteArray
- All Implemented Interfaces:
IntArray
Class UnsignedByteIndexArray represents an immutable
array of integer values between 0 and 255 inclusive that is stored
as a byte[] array. A 0xff mask is used to convert
int values to byte values.
Instances of UnsignedByteArray are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionUnsignedByteArray(byte[] ba) Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(byte[] ba, int from, int to) Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia) Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia, int valueSize) Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(int[] ia, int from, int to) Constructs a newUnsignedByteArrayinstance from the specified data.Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(IntList il, int valueSize) Constructs a newUnsignedByteArrayinstance from the specified data.UnsignedByteArray(IntList il, int from, int to) Constructs a newUnsignedByteArrayinstance from the specified data.Constructs a newUnsignedByteArrayinstance from the specified data. -
Method Summary
-
Constructor Details
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba) Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ba- an array of bytes which are interpreted as unsigned byte values between 0 and 255- Throws:
NullPointerException- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(byte[] ba, int from, int to) Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ba- an array of bytes which are interpreted as unsigned byte values between 0 and 255from- the first element to be included (inclusive)to- the last element to be included (exclusive)- Throws:
IndexOutOfBoundsException- if(from < 0 || to > ia.length)NegativeArraySizeException- ifto > fromNullPointerException- ifba == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia) Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ia- an array of integer values between 0 and 255 inclusive- Throws:
IllegalArgumentException- if(ia[j] < 0 || ia[j] > 255)for any indexjsatisfying(j >= 0 && j < ia.length)NullPointerException- ifia == null
-
UnsignedByteArray
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
il- an list of integer values between 0 and 255 inclusive- Throws:
IllegalArgumentException- if(il.get(j) < 0 || il.get(j) > 255)for any indexjsatisfying(j >= 0 && j < il.size())NullPointerException- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int valueSize) Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ia- an array of nonnegative integer valuesvalueSize- the exclusive end of the range of non-negative array values- Throws:
IllegalArgumentException- ifvalueSize < 1 || valueSize > 256IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)NullPointerException- ifia == null
-
UnsignedByteArray
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
il- an list of nonnegative integers between 0 and 255 inclusivevalueSize- the exclusive end of the range of non-negative array values- Throws:
IllegalArgumentException- if(valueSize < 1) || (valueSize > 256)IllegalArgumentException- if(ia[j] < 0 || ia[j] > valueSize)for any indexjsatisfying(j >= 0 && j < ia.length)NullPointerException- ifil == null
-
UnsignedByteArray
public UnsignedByteArray(int[] ia, int from, int to) Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
ia- an array of integer values between 0 and 255 inclusivefrom- the first element to be included (inclusive)to- the last element to be included (exclusive)- Throws:
IllegalArgumentException- if(ia[j] < 0 || ia[j] > 255)for any indexjsatisfying(j >= from && j < to)IndexOutOfBoundsException- if(from < 0 || to > ia.length)NegativeArraySizeException- ifto > fromNullPointerException- ifia == null
-
UnsignedByteArray
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
il- an list of integer values between 0 and 255 inclusivefrom- the first element to be included (inclusive)to- the last element to be included (exclusive)- Throws:
IllegalArgumentException- if(il.get(j) < 0 || il.get(j) > 255)for any indexjsatisfying(j >= from && j < to)IndexOutOfBoundsException- iffrom < 0 || to > il.lengthNegativeArraySizeException- ifto > fromNullPointerException- ifil == null
-
UnsignedByteArray
Constructs a newUnsignedByteArrayinstance from the specified data.- Parameters:
baos- a byte array output stream whose elements are interpreted as unsigned byte values between 0 and 255- Throws:
NullPointerException- ifbaos == null
-
-
Method Details
-
size
public int size()Description copied from interface:IntArrayReturns the number of elements in thisIntArray. -
get
public int get(int index) Description copied from interface:IntArrayReturns the specified array element. -
toString
-
write
Writethisbyte array to the specified output stream.- Parameters:
os- an output stream- Throws:
IOException- if an I/O error occurs
-