I am doing some kind of word search in C ++, and although there is code for implementing the map, I want to make sure that it works using a map with keys and values ββlike std :: string, and using only keys as search queries without return values.
std::vector< std::string> DictionLines; Reader DictionReader(Dictionary); DictionLines = DictionReader.getLines(); std::map<std::string, std::string> DictionaryM; for (int t = 0; t < DictionLines.size(); ++t) { DictionaryM.insert(std::pair<std::string, std::string>(DictionLines.at(t), DictionLines.at(t))); }
This code takes 349900 words in the Dictionary.txt file and saves them on the map. Each line of the dictionary is just a search word; there is no definition or any value for communication. That's why I think that just keeping a pair of the same key and value on the map in order, and using find and first / second will also be ok? Please confirm.
source share