jwutil.math
Class CombinationGenerator

java.lang.Object
  extended by jwutil.math.CombinationGenerator

public class CombinationGenerator
extends java.lang.Object

Generates combinations.

Version:
$Id: CombinationGenerator.java 2279 2005-05-28 10:24:54Z joewhaley $
Author:
jwhaley

Constructor Summary
CombinationGenerator(int n, int r)
          Create a new combination generator.
 
Method Summary
 int[] getCurrent()
          Returns the current combination.
 int[] getNext()
          Generate next combination (algorithm from Rosen p.
 java.math.BigInteger getNumLeft()
          Return number of combinations not yet generated.
 java.math.BigInteger getTotal()
          Return total number of combinations.
 boolean hasMore()
          Are there more combinations?
 void reset()
          Reset this combination generator back to the start.
 
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)
Create a new combination generator.

Parameters:
n - size of universe
r - number of elements to choose
Method Detail

reset

public void reset()
Reset this combination generator back to the start.


getNumLeft

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

Returns:
number of combinations not yet generated

hasMore

public boolean hasMore()
Are there more combinations?

Returns:
if there are more combinations

getTotal

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

Returns:
total number of combinations

getCurrent

public int[] getCurrent()
Returns the current combination.

Returns:
current combination

getNext

public int[] getNext()
Generate next combination (algorithm from Rosen p. 286).

Returns:
next combination


Copyright © 2004-2008 SUIF Compiler Group. All Rights Reserved.