std::multimap is an ordered associative container for key-value pairs that permits several values under one key. It suits dictionaries where a word can have multiple definitions. section 7.2 section 7.4
Include <map> and insert pairs with insert or construct them in place with emplace. Unlike std::map, a multimap has no operator[] or at function, so retrieval uses lower_bound and upper_bound, or equal_range, to obtain an iterator range containing every matching value. section 7.2.3
std::multimap<int, std::string> mm{
{1,"a"s}, {1,"a"s}, {3,"c"s}, {3,"g"s}, {5,"e"s}, {5,"h"s},
};
A small ordered multimap can contain duplicate keys and several different values, making the lookup range visible in a concrete initializer. section 7.2.3
For a key with matches, equal_range returns the first element not less than that key and the first element greater than it. Walk from the lower iterator to the upper iterator to process all associated pairs. The elements remain in tree nodes, and ordered associative-container operations have logarithmic complexity. section 7.2.3 section 7.4
Loading a dictionary
Read a comma-separated file line by line, split each valid line into a word and definition, normalize the key to lowercase, and emplace the pair into a std::multimap<std::string, std::string>. A lookup can then return every definition for the word. The same range technique supports the answer-smash game: find words beginning with a stem, then select the first, last, or a random matching entry for testing or play. section 7.3.1 section 7.3.3
