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 42 of file combinator.h.

Constructor & Destructor Documentation

◆ Combinator()

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

Definition at line 44 of file combinator.h.

44 : origin(v) { }

Member Function Documentation

◆ combine()

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

Definition at line 57 of file combinator.h.

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

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