/[Apache-SVN]
ViewVC logotype

Revision 140833


Jump to revision: Previous Next
Author: tobrien
Date: Fri May 16 03:55:34 2003 UTC (21 years, 4 months ago)
Changed paths: 6
Log Message:
* ContractableDoubleArray extends ExpandableDoubleArray - I sense the
need for a DoubleArray interface.

* ExpandableDoubleArray and the extension ContractableDoubleArray should
aim towards presenting a public interface that does not expose any
details of the internal.  To this end, one is no longer able to get the
internal storage array via public double[] getValues(), and the startIndex
(which was relative to the internal storage array) is no longer available.

* [Expandable|Contractable]DoubleArray now allow one to discard
elements from the front of the array.  Before this commit, one could
accomplish the same goal by changing the starting index of the element
array within the internal storage array.  This solution allowed one to
discard elements from the front of the array (as well as) reclaiming
elements by decreases the startIndex.

There were two problems with this approach (especially in
ContractableDoubleArray).   The ContractableDoubleArray can be
"compacted" at anytime thereby reseting the startIndex to zero and the
size of the internal store array to number of elements plus one.  Second,
"reclaiming" elements from the internal storage array by finagling
internal "pointers" to the start and end index seems to violate the
principles of encapsulation.  If you "discard" an element from the
front of the array, consider it unavailable.

It should be noted that calling setNumElements allows one to move the end
index of the internal element array at will.  Assume one has a 100 element
array, and one calls setNumElements(10), thereby decreasing the ending index
of the element array by 90.  The 90 "dumped" elements are not currently
reinitializied to the default double primitive value.  This is an open
question.

* Tests for ExpandableDoubleArray and ContractableDoubleArray were
refactored.  both test classes now extend a DoubleArrayAbstractTest
JUnit class which contained shared unit tests for both "implementations".
An approach like this should be adopted to test the Univariate implementations.


Changed paths

Path Details
Directoryjakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/ContractableDoubleArray.java modified , text changed
Directoryjakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/ExpandableDoubleArray.java modified , text changed
Directoryjakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/ContractableDoubleArrayTest.java added
Directoryjakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/DoubleArrayAbstractTest.java added
Directoryjakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/ExpandableDoubleArrayTest.java modified , text changed
Directoryjakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestStatisticTest.java modified , text changed

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26