Advertisement
Shaktal

CombinationGenerator.h

Jul 29th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #ifndef COMBINATION_GENERATOR_H
  2. #define COMBINATION_GENERATOR_H
  3.  
  4. #ifdef WIN32
  5.         #pragma once
  6. #endif
  7.  
  8. #define NULL nullptr
  9.  
  10. #include <vector>
  11.  
  12. class CombinationGenerator {
  13. public:
  14.     CombinationGenerator() {}
  15.     ~CombinationGenerator();
  16.  
  17.     void                    Initialize( int n, int k );
  18.     void                    Initialize( int n, int k, unsigned long long numCombinations );
  19.     std::vector<int>            NextCombination();
  20.     unsigned long long          ComputeBinomialCoefficient( int n, int k );
  21.     unsigned long long          GetNumLeft();
  22.     bool                    IsFinished();
  23.  
  24. private:
  25.     int                 n;
  26.     int                     k;
  27.     unsigned long long          m_iNumCombinations;
  28.     unsigned long long          m_iNumLeft;
  29.     std::vector<int>            m_vecCurrCombination;
  30.  
  31. }; extern CombinationGenerator* g_pCombinationGen; // You'll probably only want one of these running in your project, so we'll make a global pointer to it.
  32.  
  33. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement