From 76bc3b3677062c0c1a6b9fa08ff20d12e470159c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 02:19:09 -0500 Subject: Some old refactoring + some new refactoring --- designer.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 designer.h (limited to 'designer.h') diff --git a/designer.h b/designer.h new file mode 100644 index 0000000..38ae3c3 --- /dev/null +++ b/designer.h @@ -0,0 +1,49 @@ +#ifndef DESIGNER_H_06F8DE64 +#define DESIGNER_H_06F8DE64 + +#include +#include +#include +#include +#include +#include + +#include "cardset.h" +#include "prefix_search.h" + +struct usage { + size_t cardId; + size_t strIndex; + size_t strLen; + + usage(size_t ci, size_t si, size_t sl) + : cardId(ci), strIndex(si), strLen(sl) {} +}; + +struct solution { + const ps_type& prefix; + std::vector lengths; + size_t score; +}; + +class designer { + public: + designer(std::string text, const ps_type& titles) + : text_(std::move(text)), + titles_(titles), + solutions_(text_.length() + 1) {} + + std::list generate(std::mt19937& rng) const; + + private: + const solution& get(size_t i) const; + + solution calculate(size_t i) const; + + const std::string text_; + const ps_type& titles_; + + mutable std::vector> solutions_; +}; + +#endif /* end of include guard: DESIGNER_H_06F8DE64 */ -- cgit 1.4.1