在C ++ STL中映射equal_range()
在本教程中,我们将讨论一个程序,以了解C++STL中的mapequal_range。
此函数返回一对迭代器,这些迭代器限制了与给定参数等效的键所在的容器的范围。
示例
#include <bits/stdc++.h>
using namespace std;
int main() {
//初始化容器
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
热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语