命名空间
变体
操作

std::set<Key,Compare,Allocator>::upper_bound

来自 cppreference.cn
< cpp‎ | 容器‎ | set
 
 
 
 
iterator upper_bound( const Key& key );
(1)
const_iterator upper_bound( const Key& key ) const;
(2)
template< class K >
iterator upper_bound( const K& x );
(3) (自 C++14 起)
template< class K >
const_iterator upper_bound( const K& x ) const;
(4) (自 C++14 起)
1,2) 返回一个迭代器,指向首个大于 key 的元素。
3,4) 返回一个迭代器,指向首个与值 x 相比更大的元素。此重载仅在限定标识符 Compare::is_transparent 有效并表示类型时才参与重载解析。它允许在不构造 Key 实例的情况下调用此函数。

内容

[编辑] 参数

key - 用于比较元素的键值
x - 可以与 Key 进行比较的替代值

[编辑] 返回值

指向首个大于 key 的元素的迭代器。如果未找到此类元素,则返回过尾(past-the-end)(参见 end())迭代器。

[编辑] 复杂度

对数时间复杂度,与容器大小成对数关系。

注解

特性测试 Std 特性
__cpp_lib_generic_associative_lookup 201304L (C++14) 关联容器 中的异构比较查找,用于重载 (3,4)

[编辑] 示例

[编辑] 参见

返回与特定键匹配的元素范围
(public member function) [编辑]
返回指向首个不小于给定键的元素的迭代器
(public member function) [编辑]