private static class Combinations.LexicographicComparator
extends java.lang.Object
implements java.util.Comparator<int[]>, java.io.Serializable
lexNorm(int[]) method.| Modifier and Type | Field and Description |
|---|---|
private int |
k
Number of elements in each combination.
|
private int |
n
Size of the set from which combinations are drawn.
|
private static long |
serialVersionUID
Serializable version identifier.
|
| Constructor and Description |
|---|
Combinations.LexicographicComparator(int n,
int k) |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(int[] c1,
int[] c2) |
private long |
lexNorm(int[] c)
Computes the value (in base 10) represented by the digit
(interpreted in base
n) in the input array in reverse
order. |
private static final long serialVersionUID
private final int n
private final int k
public Combinations.LexicographicComparator(int n,
int k)
n - Size of the set from which subsets are selected.k - Size of the subsets to be enumerated.public int compare(int[] c1,
int[] c2)
compare in interface java.util.Comparator<int[]>DimensionMismatchException - if the array lengths are not
equal to k.OutOfRangeException - if an element of the array is not
within the interval [0, n).private long lexNorm(int[] c)
n) in the input array in reverse
order.
For example if c is {3, 2, 1}, and n
is 3, the method will return 18.c - Input array.OutOfRangeException - if an element of the array is not
within the interval [0, n).Copyright (c) 2003-2015 Apache Software Foundation