MATH-1027
Changed visibility of "IterationOrder" to "private". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1520611 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d3b4651afb
commit
1f72a13a37
|
@ -45,7 +45,7 @@ public class Combinations implements Iterable<int[]> {
|
||||||
* Describes the type of iteration performed by the
|
* Describes the type of iteration performed by the
|
||||||
* {@link #iterator() iterator}.
|
* {@link #iterator() iterator}.
|
||||||
*/
|
*/
|
||||||
public static enum IterationOrder {
|
private static enum IterationOrder {
|
||||||
/** Lexicographic order. */
|
/** Lexicographic order. */
|
||||||
LEXICOGRAPHIC
|
LEXICOGRAPHIC
|
||||||
}
|
}
|
||||||
|
@ -53,10 +53,19 @@ public class Combinations implements Iterable<int[]> {
|
||||||
/**
|
/**
|
||||||
* Creates an instance whose range is the k-element subsets of
|
* Creates an instance whose range is the k-element subsets of
|
||||||
* {0, ..., n - 1} represented as {@code int[]} arrays.
|
* {0, ..., n - 1} represented as {@code int[]} arrays.
|
||||||
* The {@link #iterator() iteration order} is
|
* <p>
|
||||||
* {@link IterationOrder lexicographic}.
|
* The iteration order is lexicographic: the arrays returned by the
|
||||||
*
|
* {@link #iterator() iterator} are sorted in descending order and
|
||||||
* @see #Combinations(int,int,IterationOrder)
|
* they are visited in lexicographic order with significance from
|
||||||
|
* right to left.
|
||||||
|
* For example, {@code new Combinations(4, 2).iterator()} returns
|
||||||
|
* an iterator that will generate the following sequence of arrays
|
||||||
|
* on successive calls to
|
||||||
|
* {@code next()}:<br/>
|
||||||
|
* {@code [0, 1], [0, 2], [1, 2], [0, 3], [1, 3], [2, 3]}
|
||||||
|
* </p>
|
||||||
|
* If {@code k == 0} an iterator containing an empty array is returned;
|
||||||
|
* if {@code k == n} an iterator containing [0, ..., n - 1] is returned.
|
||||||
*
|
*
|
||||||
* @param n Size of the set from which subsets are selected.
|
* @param n Size of the set from which subsets are selected.
|
||||||
* @param k Size of the subsets to be enumerated.
|
* @param k Size of the subsets to be enumerated.
|
||||||
|
@ -92,9 +101,9 @@ public class Combinations implements Iterable<int[]> {
|
||||||
* @throws org.apache.commons.math3.exception.NotPositiveException if {@code n < 0}.
|
* @throws org.apache.commons.math3.exception.NotPositiveException if {@code n < 0}.
|
||||||
* @throws org.apache.commons.math3.exception.NumberIsTooLargeException if {@code k > n}.
|
* @throws org.apache.commons.math3.exception.NumberIsTooLargeException if {@code k > n}.
|
||||||
*/
|
*/
|
||||||
public Combinations(int n,
|
private Combinations(int n,
|
||||||
int k,
|
int k,
|
||||||
IterationOrder iterationOrder) {
|
IterationOrder iterationOrder) {
|
||||||
CombinatoricsUtils.checkBinomial(n, k);
|
CombinatoricsUtils.checkBinomial(n, k);
|
||||||
this.n = n;
|
this.n = n;
|
||||||
this.k = k;
|
this.k = k;
|
||||||
|
|
|
@ -439,7 +439,7 @@ public final class CombinatoricsUtils {
|
||||||
* @throws NumberIsTooLargeException if {@code k > n}.
|
* @throws NumberIsTooLargeException if {@code k > n}.
|
||||||
*/
|
*/
|
||||||
public static Iterator<int[]> combinationsIterator(int n, int k) {
|
public static Iterator<int[]> combinationsIterator(int n, int k) {
|
||||||
return new Combinations(n, k, Combinations.IterationOrder.LEXICOGRAPHIC).iterator();
|
return new Combinations(n, k).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue