|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.models.discrete.inhomogeneous.CombinationIterator
public class CombinationIterator
This class can be used for iterating over all possible combinations (in the sense of combinatorics).
| Constructor Summary | |
|---|---|
CombinationIterator(int n,
int max)
Creates a new CombinationIterator with n elements
and at most max selected elements. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CombinationIterator(int n,
int max)
CombinationIterator with n elements
and at most max selected elements.
n - the number of elementsmax - the maximal number of selected elements| Method Detail |
|---|
public long getNumberOfCombinations(int elements)
throws IllegalArgumentException
elements - the number of selected elements
IllegalArgumentException - if elements < 0
public void setCurrentLength(int current)
throws IllegalArgumentException
current - the current used number of selected elements
IllegalArgumentException - if current < 0 or
current > maxreset()
public boolean next()
throws IllegalArgumentException
true if the method does not run out of range,
false otherwise
IllegalArgumentException - 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 combination
public void reset()
throws IllegalArgumentException
IllegalArgumentException - if the method setCurrentLength(int) was not used to
set the current used number of selected elements
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||