#include "linear_finder.h"
#include <string_view>

using std::string, std::string_view;

LinearFinder::LinearFinder(const WordList &word_list) : word_list_(word_list) {}

WordRefList LinearFinder::find_prefix(string_view search_term) const {
  WordRefList matching_words;

  for (const auto &current_word : word_list_) {
    if (current_word.starts_with(search_term)) {
      matching_words.push_back(&current_word);
    }
  }

  return matching_words;
}
