commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1407485 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/util/ResizableDoubleArray.java test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
Date Fri, 09 Nov 2012 15:15:12 GMT
Author: erans
Date: Fri Nov  9 15:15:11 2012
New Revision: 1407485

URL: http://svn.apache.org/viewvc?rev=1407485&view=rev
Log:
MATH-894
Removed call to "contract" in "addElement".

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1407485&r1=1407484&r2=1407485&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
Fri Nov  9 15:15:11 2012
@@ -298,14 +298,10 @@ public class ResizableDoubleArray implem
      * @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;
     }
 
     /**

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java?rev=1407485&r1=1407484&r2=1407485&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
Fri Nov  9 15:15:11 2012
@@ -157,16 +157,16 @@ public class ResizableDoubleArrayTest ex
         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 {



Mime
View raw message