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 T[] array
public ResizingArrayStorage(Class<T[]> arrayClazz)
DEFAULT_INITIAL_CAPACITY
.arrayClazz
- the class of the storage array.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)
If the current capacity is less or equal to the specified capacity, nothing happens.
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 © 2018. All rights reserved.