hello i am studying maps and i have this question. multimaps are just maps but 2 or more elements can have the same key? why would someone use a multimap. i mean what does it offer you?(i mean choosing this data structure) Thanks.
Let us say we want to implement a phone book, with the name as the key and phone number as data.
1 2 3 4 5 6 7 8
// one phone number per name
std::map< std::string, int > phone_book1 ;
// many phone numbers for one name
std::multimap< std::string, int > phone_book2 ;
// a sequence of phone numbers per name
std::map< std::string, std::vector<int> > phone_book3 ;
Likewise, for std::unordered_map<> and std::unordered_multimap<>