summary refs log tree commit diff stats
path: root/designer.h
diff options
context:
space:
mode:
Diffstat (limited to 'designer.h')
-rw-r--r--designer.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/designer.h b/designer.h new file mode 100644 index 0000000..38ae3c3 --- /dev/null +++ b/designer.h
@@ -0,0 +1,49 @@
1#ifndef DESIGNER_H_06F8DE64
2#define DESIGNER_H_06F8DE64
3
4#include <cstddef>
5#include <list>
6#include <memory>
7#include <random>
8#include <string>
9#include <vector>
10
11#include "cardset.h"
12#include "prefix_search.h"
13
14struct usage {
15 size_t cardId;
16 size_t strIndex;
17 size_t strLen;
18
19 usage(size_t ci, size_t si, size_t sl)
20 : cardId(ci), strIndex(si), strLen(sl) {}
21};
22
23struct solution {
24 const ps_type& prefix;
25 std::vector<size_t> lengths;
26 size_t score;
27};
28
29class designer {
30 public:
31 designer(std::string text, const ps_type& titles)
32 : text_(std::move(text)),
33 titles_(titles),
34 solutions_(text_.length() + 1) {}
35
36 std::list<usage> generate(std::mt19937& rng) const;
37
38 private:
39 const solution& get(size_t i) const;
40
41 solution calculate(size_t i) const;
42
43 const std::string text_;
44 const ps_type& titles_;
45
46 mutable std::vector<std::unique_ptr<solution>> solutions_;
47};
48
49#endif /* end of include guard: DESIGNER_H_06F8DE64 */