The unordered_map::equal_range() is an inbuilt function in C++ STL which is used to return the bounds of a range that includes all the elements in the container with a key that compares equal to k. The unordered_map containers are the container where keys are unique, the range will include one element at most. The range is defined by two iterators,
- The first one pointing to the first element of the range.
- The second one pointing past the last element of the range.
Parameters: This function accepts single parameter key which is used to hold the value to be compared.
Return Value: It returns a pair which contains a pair of iterators defining the wanted range. Where its members are pair::first and pair::second. The first one is an iterator to the lower bound of the range and the second one is an iterator to its upper bound. The elements in the range are those between these two iterators, including first pair, but not second.
Below programs illustrates the unordered_map::equal_range() function in C++ STL:
first : 1 second : 3 first : 2 second : 3 first : 3 second : 1
search for 'f' : search for 'a' : [a, b]
- Average case: Linear in the number of elements with the key k, which is constant.
- worst case: Linear in the size of the container.
- Node.js | util.types.isSymbolObject() Method
- CSS | -moz-outline-radius property
- Node.js | util.types.isPromise() Method
- Node.js | util.types.isTypedArray() Method
- Difference between Virtual function and Pure virtual function in C++
- How to create a Facebook login using an Android App?
- @include vs @extend in SASS
- Node.js | util.types.isNumberObject() Method
- Node.js | util.types.isRegExp() Method
- Node.js | util.types.isInt32Array() Method
- Node.js | util.types.isWeakSet() Method
- Node.js | Buffer.writeInt16BE() Method
- Node.js | util.types.isMap() Method
- Node.js | util.types.isWeakMap() Method
- Node.js | util.types.isMapIterator() Method
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.