The C++ function std::unordered_multimap::find() finds an element associated with key k.
If operation succeeds then methods returns iterator pointing to the element otherwise it returns an iterator pointing the unordered_map::end().
Following is the declaration for std::unordered_multimap::find() function form std::unordered_map() header.
iterator find (const key_type& k); const_iterator find (const key_type& k) const;
k − Key to be searched.
If object is constant qualified then method returns a constant iterator otherwise non-constant iterator.
Constant i.e. O(1) in average case.
Linear i.e. O(n) in worst case.
The following example shows the usage of std::unordered_multimap::find() function.
#include <iostream> #include <unordered_map> using namespace std; int main(void) { unordered_multimap<char, int> umm = { {'a', 1}, {'b', 2}, {'c', 3}, {'d', 4}, {'e', 5} }; auto it = umm.find('b'); cout << "Iterator point to " << it->first << " = " << it->second << endl; return 0; }
Let us compile and run the above program, this will produce the following result −
Iterator point to b = 2