在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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短