Samchon Framework for CPP  1.0.0
CaseGenerator.hpp
1 #pragma once
2 
3 #include <vector>
4 
5 namespace samchon
6 {
7 namespace library
8 {
24  {
25  protected:
29  size_t n_;
30 
34  size_t r_;
35 
39  size_t size_;
40 
41  public:
42  /* ----------------------------------------------------
43  CONSTRUCTORS
44  ---------------------------------------------------- */
51  CaseGenerator(size_t n, size_t r)
52  {
53  this->n_ = n;
54  this->r_ = r;
55  };
56  virtual ~CaseGenerator() = default;
57 
58  /* ----------------------------------------------------
59  ELEMENT ACCESSORS
60  ---------------------------------------------------- */
66  auto size() const -> size_t
67  {
68  return size_;
69  };
70 
76  virtual auto operator[](size_t) const->std::vector<size_t> = 0;
77 
81  auto at(size_t index) const -> std::vector<size_t>
82  {
83  if (index > this->size())
84  throw std::out_of_range("index number overs number of cases.");
85 
86  return operator[](index);
87  };
88 
92  auto n() const -> size_t
93  {
94  return n_;
95  };
96 
100  auto r() const -> size_t
101  {
102  return r_;
103  };
104 
105  public:
106  /* ----------------------------------------------------
107  TO_MATRIX
108  ---------------------------------------------------- */
115  auto toMatrix() const -> std::vector<std::vector<size_t>>
116  {
117  std::vector<std::vector<size_t>> matrix(size_, std::vector<std::size_t>(r_, 0));
118 
119  for (size_t i = 0; i < size_; i++)
120  matrix[i] = operator[](i);
121 
122  return matrix;
123  };
124  };
125 };
126 };
auto size() const -> size_t
Get size of all cases.
size_t size_
Size, the number of all cases.
size_t r_
R, size of elements of each case.
size_t n_
N, size of the candidates.
virtual auto operator[](size_t) const -> std::vector< size_t >=0
Get x&#39;th case.
auto r() const -> size_t
Get size of the R.
auto toMatrix() const -> std::vector< std::vector< size_t >>
Create a matrix containing all cases.
auto at(size_t index) const -> std::vector< size_t >
CaseGenerator(size_t n, size_t r)
Construct from size of N and R.
auto n() const -> size_t
Get size of the N.