com.rapidminer.tools.math
Class CombinationGenerator

java.lang.Object
  extended by com.rapidminer.tools.math.CombinationGenerator

public class CombinationGenerator
extends java.lang.Object

This class can be used to iterate over all combinations of r elements out of n. Usage: CombinationGenerator x = new CombinationGenerator(elements.length, 3);
while (x.hasMore()) {
int[] indices = x.getNext();
}

Author:
Ingo Mierswa

Constructor Summary
CombinationGenerator(int n, int r)
           
 
Method Summary
 int[] getNext()
          Generates the next combination by using the algorithm proposed by Rosen.
 java.math.BigInteger getNumberOfCombinationsLeft()
          Return number of combinations not yet generated.
 java.math.BigInteger getTotal()
          Returns the total number of combinations.
 boolean hasMore()
          Returns true if there are more combinations left.
 void reset()
          Resets this combination generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombinationGenerator

public CombinationGenerator(int n,
                            int r)
Method Detail

reset

public void reset()
Resets this combination generator.


getNumberOfCombinationsLeft

public java.math.BigInteger getNumberOfCombinationsLeft()
Return number of combinations not yet generated.


hasMore

public boolean hasMore()
Returns true if there are more combinations left.


getTotal

public java.math.BigInteger getTotal()
Returns the total number of combinations.


getNext

public int[] getNext()
Generates the next combination by using the algorithm proposed by Rosen.



Copyright © 2001-2009 by Rapid-I