首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::map::equal_range

std::pair<iterator,iterator> equal_range( const Key& key );

(1)

std::pair<const_iterator,const_iterator> equal_range( const Key& key ) const;

(2)

template< class K > std::pair<iterator,iterator> equal_range( const K& x );

(3)

(since C++14)

template< class K > std::pair<const_iterator,const_iterator> equal_range( const K& x ) const;

(4)

(since C++14)

返回包含容器中具有给定键的所有元素的范围。范围由两个迭代器定义,一个指向第一个元素,即不折不扣key另一个指向第一个元素更大key或者,第一个迭代器可以用lower_bound(),第二个upper_bound()...

1,2%29将密钥与key...

3,4%29将键与值进行比较。x。此重载仅在下列情况下才参与重载解析:Compare::is_transparent是有效的,并表示类型。它们允许调用此函数,而无需构造Key...

参数

key

-

key value to compare the elements to

x

-

alternative value that can be compared to Key

返回值

std::pair包含一对迭代器,定义想要的范围:第一个指向第一个元素,而不是再少点key第二个指向第一个元素更大key...

如果没有元素不折不扣key,超过-结束%28见end()%29迭代器作为第一个元素返回。类似地,如果没有元素更大key,则返回作为第二个元素的过去-结束迭代器。

复杂性

容器大小的对数。

另见

find

finds element with specific key (public member function)

upper_bound

returns an iterator to the first element greater than the given key (public member function)

lower_bound

returns an iterator to the first element not less than the given key (public member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券