From 5b669caddbfac239ed9a8ffc7a1e3f893366f871 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 21 Nov 2024 07:48:49 +0100 Subject: [PATCH] Contains --- lab2/dictionary.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lab2/dictionary.cc b/lab2/dictionary.cc index 0245fe4..6747a69 100644 --- a/lab2/dictionary.cc +++ b/lab2/dictionary.cc @@ -12,7 +12,15 @@ using std::vector; Dictionary::Dictionary() {} -bool Dictionary::contains(const string &word) const { return true; } +bool Dictionary::contains(const string &word) const { + int l = word.length(); + Word w = Word(word); + if (std::find(this->words[l].begin(), this->words[l].end(), w) != + std::end(this->words[l])) { + return true; + } + return false; +} vector Dictionary::get_suggestions(const string &word) const { vector suggestions;