Package pabeles.concurrency
Class GrowArray<D>
java.lang.Object
pabeles.concurrency.GrowArray<D>
public class GrowArray<D> extends Object
An array of objects which grows and recycles its elements automatically.
-
Constructor Summary
Constructors Constructor Description GrowArray(ConcurrencyOps.NewInstance<D> factory)GrowArray(ConcurrencyOps.NewInstance<D> factory, ConcurrencyOps.Reset<D> reset)GrowArray(ConcurrencyOps.NewInstance<D> factory, ConcurrencyOps.Reset<D> reset, Class<D> type)Specifies the internal array type. -
Method Summary
Modifier and Type Method Description Dget(int index)Dgrow()Add a new element to the array.voidreleaseInternalArray()Replaces the internal array with one of length zero.voidreset()voidresize(int length)Increases the size of the array so that it contains the specified number of elements.intsize()
-
Constructor Details
-
GrowArray
-
GrowArray
-
GrowArray
public GrowArray(ConcurrencyOps.NewInstance<D> factory, ConcurrencyOps.Reset<D> reset, Class<D> type)Specifies the internal array type. Negating the need to create an initial instance to determine the type
-
-
Method Details
-
reset
public void reset() -
resize
public void resize(int length)Increases the size of the array so that it contains the specified number of elements. If the new length is bigger than the old size then reset is called on the new elements -
grow
Add a new element to the array. Reset is called on it and it's then returned. -
releaseInternalArray
public void releaseInternalArray()Replaces the internal array with one of length zero. -
get
-
size
public int size()
-