E
- the primitive wrapper class to use (See above for details on how which classes are treated.)public abstract class PackedPrimitiveWrapperArrayList<E extends java.lang.Number> extends java.util.AbstractList<E>
PackedIntegerArrayList
using the List
interface where the element type can be any numeric primitive wrapper class of the Java API, namely Byte
,
Short
, Integer
or Long
.
The number of bits per value to be stored in the underlying packed list can be determined independently of the selected wrapper type.
Using Float
or Double
would also be possible but they would be rounded to long
before
they are stored. If instances of BigInteger
are used they would be treated as described in
BigInteger.longValue()
.
Modifier and Type | Field and Description |
---|---|
protected PackedIntegerArrayList |
packedList |
Modifier | Constructor and Description |
---|---|
protected |
PackedPrimitiveWrapperArrayList(int bitsPerValue,
long minValue,
int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E element) |
static PackedPrimitiveWrapperArrayList<java.lang.Byte> |
newByteInstance(int bitsPerValue,
long minValue,
int initialCapacity)
Creates a new instance of this class using
Byte elements. |
static PackedPrimitiveWrapperArrayList<java.lang.Integer> |
newIntegerInstance(int bitsPerValue,
long minValue,
int initialCapacity)
Creates a new instance of this class using
Integer elements. |
static PackedPrimitiveWrapperArrayList<java.lang.Long> |
newLongInstance(int bitsPerValue,
long minValue,
int initialCapacity)
Creates a new instance of this class using
Long elements. |
static PackedPrimitiveWrapperArrayList<java.lang.Short> |
newShortInstance(int bitsPerValue,
long minValue,
int initialCapacity)
Creates a new instance of this class using
Short elements. |
E |
remove(int index) |
protected void |
removeRange(int fromIndex,
int toIndex) |
E |
set(int index,
E element) |
int |
size() |
add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected PackedIntegerArrayList packedList
protected PackedPrimitiveWrapperArrayList(int bitsPerValue, long minValue, int initialCapacity)
public static PackedPrimitiveWrapperArrayList<java.lang.Byte> newByteInstance(int bitsPerValue, long minValue, int initialCapacity)
Byte
elements.bitsPerValue
- the number of bits per value that shall be storedminValue
- the minimal value to be represented by the underlying packed listinitialCapacity
- the initial number of elements the underlying packed list can take up before
resizing its arrayjava.lang.IllegalArgumentException
- if the combination if bits per value and the minimal value could lead to
values that cannot be stored in a byte
public static PackedPrimitiveWrapperArrayList<java.lang.Short> newShortInstance(int bitsPerValue, long minValue, int initialCapacity)
Short
elements.bitsPerValue
- the number of bits per value that shall be storedminValue
- the minimal value to be represented by the underlying packed listinitialCapacity
- the initial number of elements the underlying packed list can take up before
resizing its arrayjava.lang.IllegalArgumentException
- if the combination if bits per value and the minimal value could lead to
values that cannot be stored in a short
public static PackedPrimitiveWrapperArrayList<java.lang.Integer> newIntegerInstance(int bitsPerValue, long minValue, int initialCapacity)
Integer
elements.bitsPerValue
- the number of bits per value that shall be storedminValue
- the minimal value to be represented by the underlying packed listinitialCapacity
- the initial number of elements the underlying packed list can take up before
resizing its arrayjava.lang.IllegalArgumentException
- if the combination if bits per value and the minimal value could lead to
values that cannot be stored in a int
public static PackedPrimitiveWrapperArrayList<java.lang.Long> newLongInstance(int bitsPerValue, long minValue, int initialCapacity)
Long
elements.bitsPerValue
- the number of bits per value that shall be storedminValue
- the minimal value to be represented by the underlying packed listinitialCapacity
- the initial number of elements the underlying packed list can take up before
resizing its arrayjava.lang.IllegalArgumentException
- if the combination if bits per value and the minimal value could lead to
values that cannot be stored in a long
protected void removeRange(int fromIndex, int toIndex)
removeRange
in class java.util.AbstractList<E extends java.lang.Number>