| Constructor and Description | 
|---|
| DynamicArray(java.lang.Class<T> type)Creates an empty dynamic array (size=0) of the given type | 
| DynamicArray(java.lang.Class<T> type,
            int size)Creates a dynamic array of initial fixed size. | 
| DynamicArray(T[] array)Creates a new dynamic array from a fixed-size array. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | add(T value)Adds a new item to the back of the dynamic array, growing the size by one | 
| void | addAll(java.util.Collection<T> collection)Adds a collection of items to the dynamic array, growing the size of the
 array to fit all elements. | 
| void | addAll(DynamicArray<T> array)Adds a collection of items to the dynamic array, growing the size
 of the array to fit all elements | 
| DynamicArray<T> | clone() | 
| boolean | contains(T val)Searches the array to find if the item already exists in the array | 
| void | ensureCapacity(int minCapacity)Ensures the dynamic array has a minimum storage capacity
 before it will need to "grow" to fit new elements | 
| T | get(int idx)Retrieves the item at the given index. | 
| T[] | getArray()Provides direct access to the underlying array. | 
| int | indexOf(T val)Searches the array to find the index of the first element that matches the
 one provided. | 
| java.util.Iterator<T> | iterator() | 
| void | resize(int size)Sets the size of the dynamic array, either growing or trimming
 elements as required | 
| void | set(int idx,
   T value)Sets the value at the given index. | 
| int | size()Current number of elements in the dynamic array | 
| void | trimToSize()Adjusts the internal storage to match the current size of the array | 
public DynamicArray(T[] array)
array - initial arraypublic DynamicArray(java.lang.Class<T> type)
type - class type for internal storagepublic DynamicArray(java.lang.Class<T> type, int size)
type - class type for internal storagesize - initial number of elementspublic void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity - minimum storage capacitypublic int size()
public void resize(int size)
size - new size of the arraypublic void add(T value)
value - new value to add to the arraypublic void addAll(java.util.Collection<T> collection)
collection - items to append to the arraypublic void addAll(DynamicArray<T> array)
array - items to append to the arraypublic final T get(int idx)
idx - index of item to returnpublic int indexOf(T val)
val - item to search forpublic boolean contains(T val)
val - item to search forpublic T[] getArray()
public void set(int idx,
                T value)
add(Object),
 or set the dynamic array size using resize(int).idx - index of item to setvalue - value to setpublic java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public DynamicArray<T> clone()