Reuse method from "MathArrays".

Merged "if" cases.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1520622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2013-09-06 16:15:34 +00:00
parent 451e121231
commit 034ed33e47

View File

@ -131,16 +131,9 @@ public class Combinations implements Iterable<int[]> {
/** {@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) {