map equal_range() 函数在 C++ STL 中
在本教程中,我们将讨论一个程序来了解 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
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP