Removed call to "contract" in "addElement".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1407485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-11-09 15:15:11 +00:00
parent 3456d2a12a
commit 4ece62e101
2 changed files with 6 additions and 10 deletions

View File

@ -298,14 +298,10 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
* @param value to be added to end of array
*/
public synchronized void addElement(double value) {
numElements++;
if ((startIndex + numElements) > internalArray.length) {
if (internalArray.length <= startIndex + numElements) {
expand();
}
internalArray[startIndex + (numElements - 1)] = value;
if (shouldContract()) {
contract();
}
internalArray[startIndex + numElements++] = value;
}
/**

View File

@ -157,16 +157,16 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
da.addElement(2.0);
da.addElement(4.0);
da.addElement(6.0);
Assert.assertEquals(4, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(16, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(3, da.getNumElements());
da.setElement(3, 7.0);
Assert.assertEquals(4, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(16, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(4, da.getNumElements());
da.setElement(10, 10.0);
Assert.assertEquals(11, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(16, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(11, da.getNumElements());
da.setElement(9, 10.0);
Assert.assertEquals(11, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(16, ((ResizableDoubleArray) da).getInternalLength());
Assert.assertEquals(11, da.getNumElements());
try {