Package uk.ac.rdg.resc.edal.util
Class RArray
- java.lang.Object
- 
- uk.ac.rdg.resc.edal.util.RArray
 
- 
- Direct Known Subclasses:
- RLongArray,- RUByteArray,- RUIntArray,- RUShortArray
 
 public abstract class RArray extends Object Abstract superclass for resizeable integer arrays. Although values are retrieved and set using long integers, the underlying storage may be any data type. GNU Trove implements similar classes with more sophisticated features, but the internal array doubles in capacity with each resize operation. This class grows the internal array linearly, by a constant amount each time. Hence the number of elements in the internal storage array is never greater than size() + chunkSize - 1.- Author:
- Jon Blower
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidappend(long i)Appends an integer to the end of the arraybooleanequals(Object obj)abstract intgetInt(int i)Returns the ith element of the array as a 4-byte integer, irrespective of the underlying storage type.abstract longgetLong(int i)Returns the ith element of the array as a long integer, irrespective of the underlying storage type.protected abstract longgetMaxValue()protected abstract longgetMinValue()protected abstract intgetStorageLength()inthashCode()protected abstract ObjectmakeStorage(int capacity)protected abstract voidsetElement(int index, long value)intsize()abstract voidswapElements(int i1, int i2)
 
- 
- 
- 
Field Detail- 
sizeprotected int size 
 - 
chunkSizeprotected final int chunkSize 
 - 
storageprotected Object storage 
 
- 
 - 
Constructor Detail- 
RArrayprotected RArray(int chunkSize) Creates an array in which the initial capacity is set the same as the chunk size.
 - 
RArrayprotected RArray(int initialCapacity, int chunkSize)Creates an array with the given initial capacity and chunk size.- Parameters:
- initialCapacity- The number of elements in the storage array
- chunkSize- The number of storage elements that will be added each time the storage array grows.
 
 
- 
 - 
Method Detail- 
makeStorageprotected abstract Object makeStorage(int capacity) 
 - 
getStorageLengthprotected abstract int getStorageLength() 
 - 
setElementprotected abstract void setElement(int index, long value)
 - 
getMinValueprotected abstract long getMinValue() 
 - 
getMaxValueprotected abstract long getMaxValue() 
 - 
swapElementspublic abstract void swapElements(int i1, int i2)
 - 
getLongpublic abstract long getLong(int i) Returns the ith element of the array as a long integer, irrespective of the underlying storage type.- Parameters:
- i- The index of the element to return.
- Returns:
- the ith element of the array.
- Throws:
- ArrayIndexOutOfBoundsException- if- i >= size()
 
 - 
getIntpublic abstract int getInt(int i) Returns the ith element of the array as a 4-byte integer, irrespective of the underlying storage type.- Parameters:
- i- The index of the element to return.
- Returns:
- the ith element of the array.
- Throws:
- ArrayIndexOutOfBoundsException- if- i >= size()
- ArithmeticError- if the element is too large or small to be represented as a 4-byte integer.
 
 - 
appendpublic final void append(long i) Appends an integer to the end of the array- Parameters:
- i- The integer to append
- Throws:
- ArithmeticException- if- iis too large or small to be stored in the underlying storage array
 
 - 
sizepublic final int size() 
 
- 
 
-