|
||||||||||
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 of all possible combinations
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)
The combi has to be sorted. |
long |
getNumberOfCombinations(int elements)
Returns the number of possible combinations |
boolean |
next()
Steps to the next combination. |
void |
reset()
This method reset 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)
n
elements and at most max
selected
elements.
n
- the number of elementsmax
- the maximal number of selected elementsMethod 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 > max
public boolean next() throws IllegalArgumentException
true
if the method does not run out of range
IllegalArgumentException
- if the method setCurrentLength() was not used
public int[] getCombination()
public long getIndex(int[] combi)
combi
has to be sorted.
combi
- the combination
public void reset() throws IllegalArgumentException
IllegalArgumentException
- if the method setCurrentLength() was not used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |