查找与指定键匹配的元素。
iterator find(key_type key);
参数
- 键
搜索的键值。
备注
如果在控制序列的一个元素至少具有等效排序,使用 key成员函数返回指定这些元素之一的迭代器;否则返回()。hash_multiset::end (STL/CLR) 使用该属性当前设置一个元素位于与指定键的顺序控制。
示例
// cliext_hash_multiset_find.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
System::Console::WriteLine("find {0} = {1}",
L'A', c1.find(L'A') != c1.end());
System::Console::WriteLine("find {0} = {1}",
L'b', *c1.find(L'b'));
System::Console::WriteLine("find {0} = {1}",
L'C', c1.find(L'C') != c1.end());
return (0);
}
说明
请注意 find 不若干元素看起来的保证。
要求
页眉: <cliext/hash_set>
命名空间: cliext
请参见
参考
hash_multiset::equal_range (STL/CLR)