2024-03-21 12:23:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "finder.h"
|
|
|
|
#include "word_list.h"
|
|
|
|
|
2024-03-22 14:37:13 +00:00
|
|
|
#include <unordered_map>
|
2024-03-21 12:23:26 +00:00
|
|
|
|
|
|
|
class Bucket {
|
|
|
|
private:
|
2024-03-22 14:37:13 +00:00
|
|
|
std::unordered_map<char, WordRefList> directory_;
|
2024-03-21 12:23:26 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void insert(const WordList &word_list, size_t first_index, size_t last_index);
|
|
|
|
|
2024-03-21 19:16:00 +00:00
|
|
|
WordRefList find_prefix(std::string_view search_term) const;
|
2024-03-21 12:23:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BucketFinder : public Finder {
|
|
|
|
private:
|
|
|
|
std::vector<Bucket> buckets_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BucketFinder(const WordList &word_list);
|
|
|
|
|
2024-03-21 19:16:00 +00:00
|
|
|
WordRefList find_prefix(std::string_view search_term) const override;
|
2024-03-21 12:23:26 +00:00
|
|
|
};
|