public class CombinationIterator extends Object
| Constructor and Description |
|---|
CombinationIterator(int n,
int max)
|
| Modifier and Type | Method and Description |
|---|---|
int[] |
getCombination()
Returns a clone of the internal combination.
|
long |
getIndex(int[] combi)
This method returns an index for the sorted entries of a combination
combi. |
long |
getNumberOfCombinations(int elements)
Returns the number of possible combinations.
|
boolean |
next()
Steps to the next combination.
|
void |
reset()
This method resets the internal combination.
|
void |
setCurrentLength(int current)
This method sets the current used number of selected elements.
|
public CombinationIterator(int n,
int max)
n - the number of elementsmax - the maximal number of selected elementspublic long getNumberOfCombinations(int elements)
throws IllegalArgumentException
elements - the number of selected elementsIllegalArgumentException - if elements < 0public void setCurrentLength(int current)
throws IllegalArgumentException
current - the current used number of selected elementsIllegalArgumentException - if current < 0 or
current > maxreset()public boolean next()
throws IllegalArgumentException
true if the method does not run out of range,
false otherwiseIllegalArgumentException - if the method setCurrentLength(int)was not used to
set the current used number of selected elementspublic int[] getCombination()
public long getIndex(int[] combi)
combi.combi - the combinationpublic void reset()
throws IllegalArgumentException
IllegalArgumentException - if the method setCurrentLength(int) was not used to
set the current used number of selected elements