std::map<Key,T,Compare,Allocator>::upper_bound_C++中文网

std::map<Key,T,Compare,Allocator>::upper_bound

iterator upper_bound( const Key& key );

(1)

const_iterator upper_bound( const Key& key ) const;

(1)

template< class K >
iterator upper_bound( const K& x );

(2) (C++14 起)

template< class K >
const_iterator upper_bound( const K& x ) const;

(2) (C++14 起)

1) 返回指向首个大于 key 的元素的迭代器。

2) 返回指向首个比较大于x 的元素的迭代器。此重载仅若有限定 id Compare::is_transparent 合法并指代一个类型才参与重载决议。这允许调用此函数而无需构造 Key 的实例。

参数

key - 与元素比较的关键值
x - 能与 Key 比较的替用值

返回值

指向首个大于 key 的元素的迭代器。若找不到这种元素,则返回尾后(见 end() )迭代器。

复杂度

与容器大小成对数。

参阅