Parameters
- x
- Value to be searched for.
key_type is a member type defined in map containers as an alias of Key, which is the first template parameter and the type of the keys for the elements stored in the container.
Return value
An iterator to the element, if the specified key value is found, or map::end if the specified key is not found in the container.Both iterator and const_iterator are member types. In the map class template, these are bidirectional iterators.
Dereferencing this iterator accesses the element's value, which is of type pair<const Key,T>.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Output:
elements in mymap: a => 50 c => 150 |
Complexity
Logarithmic in size.See also
| map::operator[] | Access element (public member function) |
| map::count | Count elements with a specific key (public member function) |
| map::lower_bound | Return iterator to lower bound (public member function) |
| map::upper_bound | Return iterator to upper bound (public member function) |
