Thus, a typical use-case for unordered_multiset would be when you need fast lookup and don't care that the data are unordered:
- If you don't do any data lookup at all, a vector probably is a better solution;
- If you need the data to be sorted, a multiset should probably be used.
Why do we use multiset?
Similarly, a system could perform various actions, and you could use a Multiset to keep track of how many times each action occurred. In some fields of Math, a set is treated as a multiset for all purposes. For example, in Linear Algebra, a set of vectors is teated as a multiset when testing for linear dependancy.
What is Unordered_multiset?
std::unordered_multiset. ... Internally, the elements in the unordered_multiset are not sorted in any particular, but organized into buckets depending on their hash values to allow for fast access to individual elements directly by their values (with a constant average time complexity on average).