refactor: clean up

This commit is contained in:
mandlm 2024-03-22 10:59:35 +01:00
parent f080d00697
commit 66a54d85cc
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
2 changed files with 6 additions and 6 deletions

View File

@ -7,7 +7,7 @@
class Bucket { class Bucket {
private: private:
std::map<const char, WordRefList> groups_; std::map<char, WordRefList> directory_;
public: public:
void insert(const WordList &word_list, size_t first_index, size_t last_index); void insert(const WordList &word_list, size_t first_index, size_t last_index);

View File

@ -6,20 +6,20 @@
void Bucket::insert(const WordList &word_list, size_t first_index, void Bucket::insert(const WordList &word_list, size_t first_index,
size_t last_index) { size_t last_index) {
for (size_t index = first_index; index < last_index; ++index) { for (auto index = first_index; index < last_index; ++index) {
const auto &current_word = word_list[index]; const auto &current_word = word_list[index];
groups_[current_word.front()].push_back(&current_word); directory_[current_word.front()].push_back(&current_word);
} }
} }
WordRefList Bucket::find_prefix(std::string_view search_term) const { WordRefList Bucket::find_prefix(std::string_view search_term) const {
auto group_it = groups_.find(search_term.front()); auto directory_it = directory_.find(search_term.front());
if (group_it == groups_.cend()) { if (directory_it == directory_.cend()) {
return {}; return {};
} }
WordRefList result; WordRefList result;
for (const auto *word : group_it->second) { for (const auto *word : directory_it->second) {
if (word->starts_with(search_term)) { if (word->starts_with(search_term)) {
result.push_back(word); result.push_back(word);
} }