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

std::unordered_multiset::find

iterator find( const Key& key );

(1)

?

const_iterator find( const Key& key ) const;

(2)

?

1,2%29找到一个密钥相当于key...

参数

key

-

key value of the element to search for

返回值

元素的迭代器,该元素的密钥等价于key如果没有找到这样的元素,请参阅end()返回%29迭代器。

复杂性

常量,最坏情况下,容器的大小是线性的。

二次

代码语言:javascript
复制
#include <iostream>
#include <unordered_set>
 
int main()
{  
    std::unordered_multiset<int> example = {1, 2, 3, 4};
 
    auto search = example.find(2);
    if(search != example.end()) {
        std::cout << "Found " << (*search) << '\n';
    }
    else {
        std::cout << "Not found\n";
    }
}

二次

产出:

二次

代码语言:javascript
复制
Found 2

二次

另见

count

returns the number of elements matching specific key (public member function)

equal_range

returns range of elements matching a specific key (public member function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com