A variable length double array implementation and extension of ExpandableDoubleArray which automatically handles expanding and contracting double arrays.
This class extends the functionality of ExpandableDoubleArray and inherits the expansion parameters from that class. If a developer instantiates a ContractableDoubleArray and only adds values to that instance, the behavior of this class is no different from the behavior of the super-class ExpandableDoubleArray. If, on the other hand, elements are removed from the array, this implementation tests an additional parameter contractionCriteria
. The contractionCriteria
dictates when this implementation will contract the size of the internal storage array to the number of elements + 1. This check is performed after every operation that alters the number of elements in the array.
Note that the contractionCriteria must always be greater than the expansionFactor. If this were not the case (assume a contractionCriteria of 1.5f and a expansionFactor of 2.0f) an endless series of expansions and contractions would occur. If the length of this array is highly varied over time it is a good idea to trade efficient memory usage for performance. Each time an array is expanded or contracted the meaningful portions of the internal storage array are copied to a new array and the reference to the internal storage array is swapped.
@version $Revision: 1.10 $ $Date: 2003/11/19 03:28:24 $
|
|