I have some (working) code that uses a multimap<string,string>
. I'd like to change it to disallow duplicate values on the same key (obviously different values on the same key are fine, otherwise I wouldn't use a multimap).
Surprisingly the type doesn't seem to have a built-in way to avoid duplicates nor to find a key-value pair (only to find a key). But I figure someone on SO must have a ready-made workaround. Anyone?
std::map<std::string, std::set<std::string>>
would appear to have exactamondo the properties you are looking for (although inferior complexity to unordered_map
and unordered_set
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With