NChooseKBitset< N0 > Class Template Reference

Class that helps with computing subsets of K elements from a collection of N elements. More...

#include <NChooseKBitset.hpp>

Inheritance diagram for NChooseKBitset< N0 >:

[legend]
List of all members.

Public Member Functions

 NChooseKBitset ()
 Default constructor.
void setUseConstraint (bool x)
 Turn on/off usage of constraint function in choose() and generate().
virtual void choose ()
 Find all subsets.
virtual bool constraint (const bitset< N0 > &x)
 A constraint function for selecting interesting subset of subset generated. Called by choose().

Public Attributes

int N
 Number of elements in set.
int K
 Number of elements to choose.
std::vector< bitset< N0 > > subset
 Holds the subset after choose() is called.

Protected Member Functions

void generate (int N, int K, std::vector< std::bitset< N0 > > &words, size_t &c, size_t &calls, std::bitset< N0 > prefix=0)
 Recursive helper function for choose.

Protected Attributes

bool use_constraint
 Indicate whether we wish to use a constraint or not.

Detailed Description

template<int N0>
class NChooseKBitset< N0 >

Class that helps with computing subsets of K elements from a collection of N elements.


Member Function Documentation

template<int N0>
virtual bool NChooseKBitset< N0 >::constraint ( const bitset< N0 > &  x  )  [inline, virtual]

A constraint function for selecting interesting subset of subset generated. Called by choose().

Re-implement in derived class in order to choose a different interesting subset. This default implementation is trivial -- returns true.

Parameters:
x Candidate to check against constraint

Reimplemented in NChooseKBitsetExternal< Caller, N0 >.

template<int N0>
void NChooseKBitset< N0 >::generate ( int  N,
int  K,
std::vector< std::bitset< N0 > > &  words,
size_t &  c,
size_t &  calls,
std::bitset< N0 >  prefix = 0 
) [protected]

Recursive helper function for choose.

In the code, notice from the commented out code, that it is easy to introduce a constraint on the choices made. This can be useful ...

template<int N0>
void NChooseKBitset< N0 >::setUseConstraint ( bool  x  )  [inline]

Turn on/off usage of constraint function in choose() and generate().

Parameters:
x On or off?


The documentation for this class was generated from the following file:
Generated on Wed Jun 17 11:44:02 2009 for OpenFCI by  doxygen 1.4.7