From 70200735d9f31294bc17830de83bef3c8dfdb7dd Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 21 Mar 2024 13:23:42 +0100 Subject: [PATCH] feat: add one-cap word-list generator --- lib_vector_search/include/word_list.h | 1 + lib_vector_search/src/word_list.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib_vector_search/include/word_list.h b/lib_vector_search/include/word_list.h index b2365e2..b5a9300 100644 --- a/lib_vector_search/include/word_list.h +++ b/lib_vector_search/include/word_list.h @@ -11,6 +11,7 @@ public: WordList &multiply(size_t factor); WordList &shuffle(); + static WordList oneCap(); static WordList fourCaps(); static WordList fromFile(const std::filesystem::path &path); diff --git a/lib_vector_search/src/word_list.cpp b/lib_vector_search/src/word_list.cpp index e810451..6934beb 100644 --- a/lib_vector_search/src/word_list.cpp +++ b/lib_vector_search/src/word_list.cpp @@ -25,6 +25,19 @@ WordList &WordList::shuffle() { return *this; } +WordList WordList::oneCap() { + const static std::string charset_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + WordList word_list; + word_list.reserve(charset_.length()); + + for (auto char_1 : charset_) { + word_list.emplace_back(std::initializer_list({char_1})); + } + + return word_list; +}; + WordList WordList::fourCaps() { const static std::string charset_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";