std::map upper_bound() 方法
- 自 C++14 起
- C++98 起
// (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
的元素的迭代器。如果未找到此类元素,则返回一个 past-the-end 迭代器(参见 end()
)。
复杂度
对容器大小呈对数关系 - O(log size())。
异常
(无)
备注
特性测试宏:__cpp_lib_generic_associative_lookup
(用于重载 (3) 和 (4))。