Module org.scijava.collections
Package org.scijava.collections
Interface PrimitiveArray<ArrayType,BaseType>
-
- Type Parameters:
ArrayType- Type of the primitive array; e.g.,double[].BaseType- Boxed type of the array element; e.g.,Double.
- All Superinterfaces:
Collection<BaseType>,Iterable<BaseType>,List<BaseType>
- All Known Implementing Classes:
AbstractPrimitiveArray,BoolArray,ByteArray,CharArray,DoubleArray,FloatArray,IntArray,LongArray,ObjectArray,ShortArray
public interface PrimitiveArray<ArrayType,BaseType> extends List<BaseType>
Interface for primitive-type extensible arrays, modeled afterArrayList, but more performant.For primitive type arrays,
ArrayListis not a good choice because it uses boxing and unboxing to store the elements, leading to a large memory footprint as well as performance penalties.- Author:
- Johannes Schindelin, Curtis Rueden
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcapacity()Gets the current capacity of the backing array.ArrayTypecopyArray()Returns a copy of the primitive-array array.BaseTypedefaultValue()voiddelete(int index, int count)Shifts the array to delete space starting at a specified index.voidensureCapacity(int minCapacity)Makes sure the backing array at least a specified capacity.ArrayTypegetArray()Gets the fixed-size array backing this instance.intgetMaximumGrowth()Gets the maximal step size by which to grow the fixed-size array when running out of space.voidinsert(int index, int count)Shifts the array to insert space at a specified index.voidsetArray(ArrayType array)Sets the fixed-size array backing this instance.voidsetMaximumGrowth(int growth)Sets the maximal step size by which to grow the fixed-size array when running out of space.voidsetSize(int size)-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
-
-
-
Method Detail
-
getArray
ArrayType getArray()
Gets the fixed-size array backing this instance.- Returns:
- the backing array
-
setArray
void setArray(ArrayType array)
Sets the fixed-size array backing this instance.- Parameters:
array- the new backing array
-
getMaximumGrowth
int getMaximumGrowth()
Gets the maximal step size by which to grow the fixed-size array when running out of space.
-
setMaximumGrowth
void setMaximumGrowth(int growth)
Sets the maximal step size by which to grow the fixed-size array when running out of space.
-
copyArray
ArrayType copyArray()
Returns a copy of the primitive-array array.The returned array is guaranteed to have
List.size()elements.- Returns:
- the fixed-size array
-
capacity
int capacity()
Gets the current capacity of the backing array.
-
ensureCapacity
void ensureCapacity(int minCapacity)
Makes sure the backing array at least a specified capacity.After calling this method, the internal array will have at least
minCapacityelements.- Parameters:
minCapacity- the minimum capacity
-
insert
void insert(int index, int count)Shifts the array to insert space at a specified index.- Parameters:
index- the index where the space should be insertedcount- the number of values to insert
-
delete
void delete(int index, int count)Shifts the array to delete space starting at a specified index.- Parameters:
index- the index where the space should be deletedcount- the number of values to delete
-
defaultValue
BaseType defaultValue()
-
setSize
void setSize(int size)
-
-