Last active
March 17, 2017 14:01
-
-
Save ivmarkp/90a6af732cc53f4acece4bc51ab35038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unordered_map<string, int> word_to_occurrence; | |
// Build map before line 755 in query.cc by calling the method build_word_map. | |
void build_word_map(const string& list) { | |
string word; | |
int count = 0; | |
for (size_t i = 0; i <= list.length(); ++i) | |
{ | |
if (list[i] == '\t' || list[i] == '\0') | |
{ | |
if (word_to_occurrence.find(word) == word_to_occurrence.end()) | |
{ | |
word_to_occurrence[word] = count++; | |
word.clear(); | |
} | |
} else | |
word += list[i]; | |
} | |
} | |
static int word_in_list(const string& word) | |
{ | |
if (word_to_occurrence.find(word) != word_to_occurrence.end()) | |
return word_to_occurrence[word]; | |
else | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment