Package uk.ac.rdg.resc.edal.util
Class RUByteArray
- java.lang.Object
-
- uk.ac.rdg.resc.edal.util.RArray
-
- uk.ac.rdg.resc.edal.util.RUByteArray
-
public final class RUByteArray extends RArray
A resizeable array of unsigned bytes. Data are stored in an array of primitive bytes.
Instances of this class are not thread safe.
- Author:
- Jon Blower
-
-
Constructor Summary
Constructors Constructor Description RUByteArray(int chunkSize)Creates an array in which the initial capacity is set the same as the chunk size.RUByteArray(int initialCapacity, int chunkSize)Creates an array with the given initial capacity and chunk size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetInt(int i)Returns the ith element of the array as a 4-byte integer, irrespective of the underlying storage type.longgetLong(int i)Returns the ith element of the array.protected longgetMaxValue()protected longgetMinValue()protected intgetStorageLength()protected byte[]makeStorage(int capacity)protected voidsetElement(int index, long value)voidswapElements(int i1, int i2)
-
-
-
Field Detail
-
MAX_VALUE
public static final int MAX_VALUE
The maximum value that can be stored in this array- See Also:
- Constant Field Values
-
MIN_VALUE
public static final int MIN_VALUE
The minimum value that can be stored in this array- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RUByteArray
public RUByteArray(int chunkSize)
Creates an array in which the initial capacity is set the same as the chunk size.
-
RUByteArray
public RUByteArray(int initialCapacity, int chunkSize)Creates an array with the given initial capacity and chunk size.- Parameters:
initialCapacity- The number of elements in the storage arraychunkSize- The number of storage elements that will be added each time the storage array grows.
-
-
Method Detail
-
makeStorage
protected byte[] makeStorage(int capacity)
- Specified by:
makeStoragein classRArray
-
getLong
public long getLong(int i)
Returns the ith element of the array.- Specified by:
getLongin classRArray- Parameters:
i- The index of the element to return.- Returns:
- the ith element of the array.
- Throws:
ArrayIndexOutOfBoundsException- ifi >= size()
-
getInt
public int getInt(int i)
Description copied from class:RArrayReturns the ith element of the array as a 4-byte integer, irrespective of the underlying storage type.
-
getStorageLength
protected int getStorageLength()
- Specified by:
getStorageLengthin classRArray
-
setElement
protected void setElement(int index, long value)- Specified by:
setElementin classRArray
-
swapElements
public void swapElements(int i1, int i2)- Specified by:
swapElementsin classRArray
-
getMinValue
protected long getMinValue()
- Specified by:
getMinValuein classRArray
-
getMaxValue
protected long getMaxValue()
- Specified by:
getMaxValuein classRArray
-
-