//#(execute) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/5Tfr6xxa5
#include <string>
#include <string_view>
#include <vector>
#include <map> // multimap
namespace qw::impl_multimap {
using std::vector; using std::multimap;
using std::string; using std::string_view;
class index_impl {
vector<string> entries;
multimap<string,size_t> qindex;
public:
void add(string_view normalized, string_view original);
string getBestMatch(string_view normalized) const;
size_t size() const {
return entries.size();
}
private:
vector<string> qgramify(string_view normalized) const;
static constexpr size_t Q = 3;
static const std::string PREFIX;
static const std::string SUFFIX;
public: // test interface
vector<string> _qgramify(string_view n) const { return qgramify(n); }
static size_t _q() { return Q; }
static std::string _prefix() { return PREFIX; }
static std::string _suffix() { return SUFFIX; }
};
} // namespace qw::impl_multimap