commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1520622 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java
Date Fri, 06 Sep 2013 16:15:35 GMT
Author: erans
Date: Fri Sep  6 16:15:34 2013
New Revision: 1520622

URL: http://svn.apache.org/r1520622
Log:
Reuse method from "MathArrays".
Merged "if" cases.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java?rev=1520622&r1=1520621&r2=1520622&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Combinations.java
Fri Sep  6 16:15:34 2013
@@ -131,16 +131,9 @@ public class Combinations implements Ite
     /** {@inheritDoc} */
     @Override
     public Iterator<int[]> iterator() {
-        if (k == 0) {
-            return new SingletonIterator(new int[]{});
-        }
-        if (k == n) {
-            // TODO: once getNatural is extracted from RandomDataGenerator, use it
-            final int[] natural = new int[n];
-            for (int i = 0; i < n; i++) {
-                natural[i] = i;
-            }
-            return new SingletonIterator(natural);
+        if (k == 0 ||
+            k == n) {
+            return new SingletonIterator(MathArrays.natural(k));
         }
 
         switch (iterationOrder) {



Mime
View raw message