public member function
size_type count (const value_type& val) const;
Count elements with a specific key
Searches the container for elements equivalent to val and returns the number of matches.
Two elements of a multiset are considered equivalent if the container's comparison object returns false reflexively (i.e., no matter the order in which the elements are passed as arguments).
- Value to search for.
Member type value_type is the type of the elements in the container, defined in multiset as an alias of its first template parameter (T).
The number of elements in the container that are equivalent to val.
Member type size_type is an unsigned integral type.
int main ()
std::multiset<int> mymultiset (myints,myints+7);
std::cout << "73 appears " << mymultiset.count(73) << " times in mymultiset.\n";
73 appears 3 times in mymultiset.
Logarithmic in size and linear in the number of matches.
The container is accessed.
Concurrently accessing the elements of a multiset is safe.
Strong guarantee: if an exception is thrown, there are no changes in the container.