multiset::find() method in C++ STL

Multisets are associative containers available in the C++ Standard Library. They are similar to sets with an addition that multiple keys with equivalent values are allowed. The multiset::find() is a method available in the STL that searches the set and returns an iterator to the first occurrence of a specific key if found.


set_name.find( key );

Parameters: The multiset::find() accepts a single parameter:
key: Key to search for
Return value: An iterator to the element with the given key. multiset::end() otherwise

Example of multiset::find() method

#include <iostream>
#include <set>

using namespace std;

int main()
   multiset<int> m;
  cout<<"Index of key 4 is: "<<distance(m.begin(), m.find(4));


Index of key 4 is: 5

This article is written by

Please comment below, if you have any doubts or find any error in the above article.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Full Stack Integrated Bootcamp Free Trial

  • Please enter a number from 7000000000 to 9999999999.