edu.umd.cfar.lamp.viper.util
Class Combinator

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.Combinator

public class Combinator
extends java.lang.Object

This class takes in an array of Objects and runs through all possible k-combinations. See Doug Moore's Bit Twiddling.

Author:
David Mihalcik
See Also:
Permuter

Constructor Summary
Combinator(java.lang.Object[] set, int lengthOfPermutation)
          Constructs a new Combinator to iterate through all combinations of the specified length on the given set.
 
Method Summary
 java.lang.Object[] getCurrentCombination()
          Returns the most recently generated combination.
 java.lang.Object[] getNextCombination()
          Returns the lexicographically next combination.
protected  java.math.BigInteger leastItem(java.math.BigInteger comb)
          Returns the least item in a combination.
 java.lang.String toString()
          Prints out the last combination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Combinator

public Combinator(java.lang.Object[] set,
                  int lengthOfPermutation)
Constructs a new Combinator to iterate through all combinations of the specified length on the given set.

Parameters:
set - The data to iterate over.
lengthOfPermutation - The length of the sets to generate.
Method Detail

leastItem

protected java.math.BigInteger leastItem(java.math.BigInteger comb)
Returns the least item in a combination. eg if bits 2, 4, and 5 are set, returns an int with just bit 2 set (4).

Parameters:
comb - The combination to find the least set bit in.
Returns:
A number with just one bit set, the least significant of those set in the parameter.

getNextCombination

public java.lang.Object[] getNextCombination()
Returns the lexicographically next combination.

Returns:
The next combination.

getCurrentCombination

public java.lang.Object[] getCurrentCombination()
Returns the most recently generated combination.

Returns:
The last combination.

toString

public java.lang.String toString()
Prints out the last combination.

Returns:
The last combination with french braces and comma seperated.