请问stl中set的用法

tmp_love3 2007-04-24 11:45:42
请问stl中set的用法
lower_bound和upper_bound怎么用啊,有什么区别?
...全文
370 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
www.cppreference.com/cppset/index.html
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
lower_bound
Syntax:

#include <set>
iterator lower_bound( const key_type& key );

The lower_bound() function returns an iterator to the first element which has a value greater than or equal to key.

=============================
upper_bound
Syntax:

#include <set>
iterator upper_bound( const key_type& key );

The function upper_bound() returns an iterator to the first element in the set with a key greater than key.
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
C++ Sets

The C++ Set is an associative container that contains a sorted set of unique objects.

Display all entries for C++ Sets on one page, or view entries individually:
Container constructors & destructors default methods to allocate, copy, and deallocate sets
Container operators assign and compare sets
begin returns an iterator to the beginning of the set
clear removes all elements from the set
count returns the number of elements matching a certain key
empty true if the set has no elements
end returns an iterator just past the last element of a set
equal_range returns iterators to the first and just past the last elements matching a specific key
erase removes elements from a set
find returns an iterator to specific elements
insert insert items into a set
key_comp returns the function that compares keys
lower_bound returns an iterator to the first element greater than or equal to a certain value
max_size returns the maximum number of elements that the set can hold
rbegin returns a reverse_iterator to the end of the set
rend returns a reverse_iterator to the beginning of the set
size returns the number of items in the set
swap swap the contents of this set with another
upper_bound returns an iterator to the first element greater than a certain value
value_comp returns the function that compares values
taodm 2007-04-24
  • 打赏
  • 举报
回复
这个,看一下帮助文档就清楚了。

65,213

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧