Electroneum
tools::Combinator< T > Class Template Reference

#include <combinator.h>

Public Member Functions

 Combinator (const std::vector< T > &v)
 
std::vector< std::vector< T > > combine (size_t k)
 

Detailed Description

template<typename T>
class tools::Combinator< T >

Definition at line 43 of file combinator.h.

Constructor & Destructor Documentation

◆ Combinator()

template<typename T >
tools::Combinator< T >::Combinator ( const std::vector< T > &  v)
inline

Definition at line 45 of file combinator.h.

45 : origin(v) { }

Member Function Documentation

◆ combine()

template<typename T >
std::vector< std::vector< T > > tools::Combinator< T >::combine ( size_t  k)

Definition at line 58 of file combinator.h.

59 {
60  if (k > origin.size())
61  {
62  throw std::runtime_error("k must be smaller than elements number");
63  }
64 
65  if (k == 0)
66  {
67  throw std::runtime_error("k must be greater than zero");
68  }
69 
70  combinations.clear();
71  doCombine(0, k);
72  return combinations;
73 }

The documentation for this class was generated from the following file: