在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 祝福语美甲店员工简短