Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
map equal_range() in C++ STL
In this tutorial, we will be discussing a program to understand map equal_range in C++ STL.
This function returns a pair of iterators that bounds the range of the container in which the key equivalent to the given parameter resides.
Example
#include <bits/stdc++.h>
using namespace std;
int main() {
//initializing container
map<int, int> mp;
mp.insert({ 4, 30 });
mp.insert({ 1, 40 });
mp.insert({ 6, 60 });
pair<map<int, int>::iterator,
map<int, int>::iterator>
it;
it = mp.equal_range(1);
cout << "The lower bound is " << it.first->first<< ":" << it.first->second;
cout << "\nThe upper bound is "<< it.second->first<< ":" << it.second->second;
return 0;
}
Output
The lower bound is 1:40 The upper bound is 4:30
Advertisements