2 #include <samchon/library/CaseGenerator.hpp> 4 #define TEMPLATE_FACTORIAL_CASE_MACRO(N) case N: size_ = factorial<N>::value; break; 26 std::vector<size_t> atoms;
28 template<const
size_t N>
struct factorial
30 enum { value = N * factorial<N - 1>::value };
32 template<>
struct factorial<1>
50 TEMPLATE_FACTORIAL_CASE_MACRO(1)
51 TEMPLATE_FACTORIAL_CASE_MACRO(2)
52 TEMPLATE_FACTORIAL_CASE_MACRO(3)
53 TEMPLATE_FACTORIAL_CASE_MACRO(4)
54 TEMPLATE_FACTORIAL_CASE_MACRO(5)
55 TEMPLATE_FACTORIAL_CASE_MACRO(6)
56 TEMPLATE_FACTORIAL_CASE_MACRO(7)
57 TEMPLATE_FACTORIAL_CASE_MACRO(8)
58 TEMPLATE_FACTORIAL_CASE_MACRO(9)
59 TEMPLATE_FACTORIAL_CASE_MACRO(10)
60 TEMPLATE_FACTORIAL_CASE_MACRO(11)
61 TEMPLATE_FACTORIAL_CASE_MACRO(12)
62 TEMPLATE_FACTORIAL_CASE_MACRO(13)
63 TEMPLATE_FACTORIAL_CASE_MACRO(14)
64 TEMPLATE_FACTORIAL_CASE_MACRO(15)
68 size_ = factorial<15>::value;
69 for (
size_t i = 16; i <
n; i++)
75 for (
size_t i = n - r + 1; i <=
n; i++)
80 for (
size_t i = 0; i <
n; i++)
85 virtual auto operator[](
size_t index)
const->std::vector<
size_t>
override 87 std::vector<size_t> atoms = this->atoms;
88 std::vector<size_t> row(
r_, NULL);
90 for (
size_t i = 0; i < row.size(); i++)
92 size_t item = index % atoms.size();
93 index = index / atoms.size();
96 atoms.erase(atoms.begin() + item);
size_t size_
Size, the number of all cases.
size_t r_
R, size of elements of each case.
PermutationGenerator(size_t n, size_t r)
Construct from size of N and R.
A permutation case generator.
virtual auto operator[](size_t index) const -> std::vector< size_t > override
Get x'th case.
auto r() const -> size_t
Get size of the R.
auto n() const -> size_t
Get size of the N.