MATH-894
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:
parent
3456d2a12a
commit
4ece62e101
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue