The map::equal_range() is a built-in function in C++ STL which returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to k. Since the map container only contains unique key, hence the first iterator in the pair returned thus points to the element and the second iterator in the pair points to the next key which comes after key K. If there are no matches with key K, the range returned is of length 1 with both iterators pointing to the an element which has a key denoting the size of map and elements as 0.
Parameters: This function accepts a single mandatory parameter key which specifies the element whose range in the container is to be returned.
Return Value: The function returns an iterator of pairs as explained above.
Below programs illustrate the above method:
The lower bound is 1:40 The upper bound is 4:30
The lower bound is 3:0 The upper bound is 3:0
- Find the number of p-sided squares in a grid with K blacks painted
- Find the Deepest Node in a Binary Tree Using Queue STL - SET 2
- C++ program to compare two Strings using Operator Overloading
- not1 and not2 function templates in C++ STL with Examples
- Go vs C++
- Trie Data Structure using smart pointer and OOP in C++
- Modular Exponentiation of Complex Numbers
- Minimum Bitwise XOR operations to make any two array elements equal
- std::hash class in C++ STL
- History of C++
- What are Forward declarations in C++
- __builtin_inf() functions of GCC compiler
- Structures in C++
- Variables in C++
- Implementing Forward Iterator in BST
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.