ArrayType - Type of the primitive array; e.g., double[].BaseType - Boxed type of the array element; e.g., Double.public abstract class AbstractPrimitiveArray<ArrayType,BaseType> extends AbstractList<BaseType> implements PrimitiveArray<ArrayType,BaseType>
This class makes it easy to implement extensible arrays backed by fixed-size primitive type arrays, re-allocating and copying data as needed. To avoid frequent re-allocation, by default, the fixed-size array will be expanded by 50% when running out of space.
modCount| Constructor and Description |
|---|
AbstractPrimitiveArray(Class<BaseType> type)
Constructs an extensible array of primitive type elements, backed by a
fixed-size array.
|
AbstractPrimitiveArray(Class<BaseType> type,
ArrayType array)
Constructs an extensible array of primitive type elements, backed by the
given fixed-size array.
|
AbstractPrimitiveArray(Class<BaseType> type,
int size)
Constructs an extensible array of primitive type elements, backed by a
fixed-size array.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
add(int index,
BaseType element) |
int |
capacity()
Gets the current capacity of the backing array.
|
protected void |
checkBounds(int index)
Checks that the index is less than the size of the array.
|
void |
clear() |
ArrayType |
copyArray()
Returns a copy of the primitive-array array.
|
void |
delete(int index,
int count)
Shifts the array to delete space starting at a specified index.
|
void |
ensureCapacity(int minCapacity)
Makes sure the backing array at least a specified capacity.
|
int |
getMaximumGrowth()
Gets the maximal step size by which to grow the fixed-size array when
running out of space.
|
void |
insert(int index,
int count)
Shifts the array to insert space at a specified index.
|
BaseType |
remove(int index) |
abstract BaseType |
set(int index,
BaseType element) |
void |
setMaximumGrowth(int growth)
Sets the maximal step size by which to grow the fixed-size array when
running out of space.
|
void |
setSize(int size) |
int |
size() |
add, addAll, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitdefaultValue, getArray, setArrayadd, addAll, addAll, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArrayparallelStream, removeIf, streampublic AbstractPrimitiveArray(Class<BaseType> type)
type - the class of the primitive typepublic AbstractPrimitiveArray(Class<BaseType> type, int size)
type - the class of the primitive typesize - the initial sizepublic int getMaximumGrowth()
PrimitiveArraygetMaximumGrowth in interface PrimitiveArray<ArrayType,BaseType>public void setMaximumGrowth(int growth)
PrimitiveArraysetMaximumGrowth in interface PrimitiveArray<ArrayType,BaseType>public ArrayType copyArray()
PrimitiveArray
The returned array is guaranteed to have List.size() elements.
copyArray in interface PrimitiveArray<ArrayType,BaseType>public int capacity()
capacity in interface PrimitiveArray<ArrayType,BaseType>public void ensureCapacity(int minCapacity)
PrimitiveArray
After calling this method, the internal array will have at least
minCapacity elements.
ensureCapacity in interface PrimitiveArray<ArrayType,BaseType>minCapacity - the minimum capacitypublic void insert(int index,
int count)
insert in interface PrimitiveArray<ArrayType,BaseType>index - the index where the space should be insertedcount - the number of values to insertpublic void delete(int index,
int count)
delete in interface PrimitiveArray<ArrayType,BaseType>index - the index where the space should be deletedcount - the number of values to deletepublic abstract void add(int index,
BaseType element)
public BaseType remove(int index)
public int size()
public void clear()
clear in interface Collection<BaseType>clear in interface List<BaseType>clear in class AbstractList<BaseType>protected void checkBounds(int index)
Copyright © 2009–2016 SciJava. All rights reserved.