std::set upper_bound() 方法
- 自 C++14 起
- 直到 C++14
// (1) Non const version
iterator upper_bound( const Key& key );
// (2) Const version
const_iterator upper_bound( const Key& key ) const;
// (3) Non const version
template< class K >
iterator upper_bound( const K& x );
// (4) Const version
template< class K >
const_iterator upper_bound( const K& x ) const;
// (1) Non const version
iterator upper_bound( const Key& key );
// (2) Const version
const_iterator upper_bound( const Key& key ) const;
- (1-2) 返回一个迭代器,指向**第一个大于**
key
的元素。 - (3-4) 返回一个迭代器,指向**第一个与值
x
比较结果大于**该值的元素。此重载仅当限定IDCompare::is_transparent
有效且表示一个类型时才参与重载决议。它允许在不构造Key
实例的情况下调用此函数。
参数
key
- 用于与元素比较的键值x
- 可以与 Key 比较的替代值
返回值
迭代器指向**第一个大于 key
的元素**。
如果没有找到这样的元素,则返回一个 past-the-end 迭代器(参见 end()
)。
复杂度
对容器大小呈对数关系 - O(log size())。
异常
(无)
备注
特性测试宏:__cpp_lib_generic_unordered_lookup
(用于重载 (3-4))。
示例
重要
本节需要改进。您可以通过编辑此文档页面来帮助我们。