|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.ou.mlfw.ladder.CombinationGenerator
public class CombinationGenerator
Constructor Summary | |
---|---|
CombinationGenerator(int n,
int r)
Create a new CombinationGenerator over the given population and selection sets. |
Method Summary | |
---|---|
static java.math.BigInteger |
combinations(int n,
int r)
A literal implementation of the combinations formula. |
static java.math.BigInteger |
factorial(int n)
|
static java.math.BigInteger |
fastCombinations(int n,
int r)
An optimized implementation of the combinations formula. |
int[] |
getNext()
Generate next combination (algorithm from Rosen p. |
java.math.BigInteger |
getNumLeft()
|
java.math.BigInteger |
getTotal()
|
boolean |
hasMore()
|
static java.math.BigInteger |
multiplyRange(int smaller,
int bigger)
Multiply the given range of integers (incrementing by 1), inclusive of both smaller and bigger, unless smaller == bigger, in which case that value will be returned. |
void |
reset()
Clear the array, and reset the remaining number of combinations to the total calculated number of combinations for (n r). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CombinationGenerator(int n, int r)
n
- The size of the total population set.r
- The size of the selection set.Method Detail |
---|
public static java.math.BigInteger multiplyRange(int smaller, int bigger)
smaller
- The lower bound of the range to multiply, inclusive.bigger
- The upper bound of the range to multiply, inclusive.
public static java.math.BigInteger factorial(int n)
n
- The integer value to calculate the factorial of
public static java.math.BigInteger combinations(int n, int r)
n
- The size of the total population set.r
- The size of the selection set.
public static java.math.BigInteger fastCombinations(int n, int r)
n
- The size of the total population set.r
- The size of the selection set.
public void reset()
public java.math.BigInteger getNumLeft()
public boolean hasMore()
public java.math.BigInteger getTotal()
public int[] getNext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |