Search code examples
c++stlcontainersmultimapmultiset

"multiset" & "multimap" - What's the point?


As the question states ... I don't get the point about multisets / multimaps.

So, what's the purpose?


Solution

  • Some use cases:

    multimap

    • With ZIP code as a key, all people which have that ZIP code
    • With account ID as key, all open orders of that person/account
    • A dictionary, with per keyword various explanations

    multiset

    is in essence a map with a key and a integer count.

    • The inventory of a shop, all products have their key and the amount still available is the value
    • accumulated sales data of a shop, every time a product is sold the product id get's added to the multiset thereby increasing the amount sold