T
- element class.public class ResizingArrayStorage<T> extends Object
Modifier and Type | Field and Description |
---|---|
T[] |
array |
static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity of the array storage.
|
Constructor and Description |
---|
ResizingArrayStorage(Class<T[]> arrayClazz)
Constructor.
|
ResizingArrayStorage(Class<T[]> arrayClazz,
int initialCapacity)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
ensureCapacity(int minCapacity)
Ensures that the storage has room for at least the specified number
of elements.
|
void |
hintNextCapacity(int nextCapacityHint)
Sets the minimum new capacity that the storage will have
after the next resize.
|
void |
setAll(T value)
Sets all the elements in the array to the specified value.
|
boolean |
shrink(int maxCapacity)
Shrinks the storage to the specified maximum capacity.
|
void |
swap(ResizingArrayStorage<T> other) |
public static final int DEFAULT_INITIAL_CAPACITY
public ResizingArrayStorage(Class<T[]> arrayClazz)
DEFAULT_INITIAL_CAPACITY
.arrayClazz
- the class of the storage array.public ResizingArrayStorage(Class<T[]> arrayClazz, int initialCapacity)
arrayClazz
- the class of the storage array.initialCapacity
- the initial capacity.public boolean ensureCapacity(int minCapacity)
minCapacity
- the minimal number of elements the storage array
has to provide room for.true
iff the storage array had to be resized,
false
otherwise.public boolean shrink(int maxCapacity)
maxCapacity
- the maximal number of elements the storage array
has to provide room for.true
iff the storage array had to be resized,
false
otherwise.public void hintNextCapacity(int nextCapacityHint)
nextCapacityHint
- the minimum next capacity hint.public void setAll(T value)
value
- the value.public void swap(ResizingArrayStorage<T> other)
Copyright © 2015. All Rights Reserved.