博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C ++ STL中的set :: upper_bound()函数
阅读量:2528 次
发布时间:2019-05-11

本文共 1942 字,大约阅读时间需要 6 分钟。

C ++ STL set :: upper_bound()函数 (C++ STL set::upper_bound() function)

set::upper_bound() function is a predefined function, it is used to get the upper bound of any element in a set.

set :: upper_bound()函数是预定义的函数,用于获取集合中任何元素的上限。

it finds upper bound of any desired element from the set. Upper bound of any_element means the first number in the set that's immediate next to any_element.

它从集合中找到任何所需元素的上限。 上界any_element手段的第一个号码的组的直接旁边any_element。

Prototype:

原型:

set
st; //declaration set
st::iterator it; //iterator declaration it=st.upper_bound(T key);

Parameter: T key; //T is the data type

参数: T键; // T是数据类型

Return type: If upper_bound of the key exists in the set iterator pointer to the upper bound, Else, st.end()

返回类型:如果键的upper_bound存在于指向顶部上限的设置迭代器指针中,否则为st.end()

Usage:

用法:

The function finds upper bound of any desired element from the set. Upper bound of x is immediate next of x.

该函数从集合中找到任何所需元素的上限。 x的上限紧邻x。

Example:

例:

For a set of integer,    set
st; st.insert(6); st.insert(4); st.insert(10); set content: //sorted always(ordered) 4 6 10 it=st.upper_bound(4) Print *it; //6

Header file to be included:

包含的头文件:

#include 
#include
OR #include

C++ implementation:

C ++实现:

#include 
using namespace std;void printSet(set
st){
set
:: iterator it; cout<<"Set contents are:\n"; if(st.empty()){
cout<<"empty set\n"; return; } for(it=st.begin();it!=st.end();it++) cout<<*it<<" "; cout<
st; set
:: iterator it; cout<<"inserting 4\n"; st.emplace(4); cout<<"inserting 6\n"; st.emplace(6); cout<<"inserting 10\n"; st.emplace(10); printSet(st); //printing current set cout<<"upper bound of 6 is "<<*(st.upper_bound(6)); return 0;}

Output

输出量

Example of upper_bound functioninserting 4inserting 6inserting 10Set contents are:4 6 10upper bound of 6 is 10

翻译自:

转载地址:http://yexzd.baihongyu.com/

你可能感兴趣的文章
如何使用FireBug插件查询元素的xPath属性
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>
亿级曝光品牌视频的幕后设定
查看>>
ARPA
查看>>
JSP开发模式
查看>>
我的Android进阶之旅------&gt;Android嵌入图像InsetDrawable的使用方法
查看>>
Detours信息泄漏漏洞
查看>>
win32使用拖放文件
查看>>
Android 动态显示和隐藏软键盘
查看>>
raid5什么意思?怎样做raid5?raid5 几块硬盘?
查看>>
【转】how can i build fast
查看>>
接口测试-jmeter
查看>>
js便签笔记(5)——Dean Edwards大牛的跨浏览器AddEvent()设计(不知道是不是jQuery事件系统的原型)...
查看>>
重构wangEditor(web富文本编辑器),欢迎指正!
查看>>
null?对象?异常?到底应该如何返回错误信息
查看>>
django登录验证码操作
查看>>
(简单)华为Nova青春 WAS-AL00的USB调试模式在哪里开启的流程
查看>>
UIScrollerView ,UIPageControl混搭使用,添加定时器,无限循环滚动
查看>>
图论知识,博客
查看>>