Reputation: 60
I need a data structure that is able to store elements along with their frequencies. Additionally, I need to be able to find efficiently how many distinct elements I currently have. I was looking into std::unordered_multiset
since I can insert each element and then by simply invoking the count(key)
method I am able to find the frequency of an element.
I was expecting that when I would invoke the size()
method of std::unordered_multiset
I would be able to get the total number of distinct elements in the set. Though, that seems to not be the case and the total number of inserted elements is returned.
How could I find the total number of distinct elements in std::unordered_multiset
. Would an std::unordered_map
be preferred for this specific use case?
Upvotes: 0
Views: 2098