이 튜토리얼에서는 C++ STL에서 map equal_range를 이해하는 프로그램에 대해 논의할 것입니다.
이 함수는 주어진 매개변수에 해당하는 키가 있는 컨테이너 범위를 제한하는 반복자 쌍을 반환합니다.
예시
#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;
} 출력
The lower bound is 1:40 The upper bound is 4:30