C ++中的upper_bound
在这里,我们将看到C++STL中的upper_bound()函数。此函数返回一个迭代器,该迭代器指向容器中的第一个元素,该元素被认为位于val之后。语法如下:
iterator upper_bound (const value_type& val); const_iterator upper_bound (const value_type& val) const;
返回值是一个迭代器,指向容器中被认为位于val之后的第一个元素。
示例
#include <iostream>
#include <set>
using namespace std;
int main () {
set<int> myset;
set<int>::iterator itlow,itup;
for (int i = 1; i < 10; i++) myset.insert(i*10);
itup = myset.upper_bound (60);
myset.erase(itup);
cout << "myset包含:";
for (set<int>::iterator it = myset.begin(); it!=myset.end(); ++it)
cout << ' ' << *it;
}输出结果
myset包含: 10 20 30 40 50 60 80 90
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬