
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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
- Related Articles
- map::at() and map::swap() in C++ STL
- map emplace() in C++ STL
- map get_allocator in C++ STL
- map value_comp() in C++ STL
- map::clear() in C++ STL
- map insert() in C++ STL
- map operator= in C++ STL
- map::empty() in C++ STL
- map::size() in C++ STL
- map::at() in C++ STL
- map max_size() in C++ STL
- Set vs Map in C++ STL
- map emplace_hint() function in C++ STL
- map erase() function in C++ STL
- map find() function in C++ STL

Advertisements