18 lines
426 B
C++
18 lines
426 B
C++
#include "linear_finder.h"
|
|
|
|
LinearFinder::LinearFinder(const vector<string> &word_list)
|
|
: word_list_(word_list) {}
|
|
|
|
vector<const string *>
|
|
LinearFinder::find_prefix(string_view search_term) const {
|
|
vector<const string *> matching_words;
|
|
|
|
for (const auto ¤t_word : word_list_) {
|
|
if (current_word.starts_with(search_term)) {
|
|
matching_words.push_back(¤t_word);
|
|
}
|
|
}
|
|
|
|
return matching_words;
|
|
}
|