Share via


hash_multimap::find (STL/CLR)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at hash_multimap::find (STL/CLR).

Finds an element that matches a specified key.

Syntax

iterator find(key_type key);  

Parameters

key
Key value to search for.

Remarks

If at least one element in the controlled sequence has equivalent ordering with key, the member function returns an iterator designating one of those elements; otherwise it returns hash_multimap::end (STL/CLR)(). You use it to locate an element currently in the controlled sequence that matches a specified key.

Example

// cliext_hash_multimap_find.cpp   
// compile with: /clr   
#include <cliext/hash_map>   
  
typedef cliext::hash_multimap<wchar_t, int> Myhash_multimap;   
int main()   
    {   
    Myhash_multimap c1;   
    c1.insert(Myhash_multimap::make_value(L'a', 1));   
    c1.insert(Myhash_multimap::make_value(L'b', 2));   
    c1.insert(Myhash_multimap::make_value(L'c', 3));   
  
// display contents " [a 1] [b 2] [c 3]"   
    for each (Myhash_multimap::value_type elem in c1)   
        System::Console::Write(" [{0} {1}]", elem->first, elem->second);   
    System::Console::WriteLine();   
  
    System::Console::WriteLine("find {0} = {1}",   
        L'A', c1.find(L'A') != c1.end());   
  
    Myhash_multimap::iterator it = c1.find(L'b');   
    System::Console::WriteLine("find {0} = [{1} {2}]",   
        L'b', it->first, it->second);   
  
    System::Console::WriteLine("find {0} = {1}",   
        L'C', c1.find(L'C') != c1.end());   
    return (0);   
    }  
  
 [a 1] [b 2] [c 3]  
find A = False  
find b = [b 2]  
find C = False  

Description

Note that find does not guarantee which of several element it finds.

Requirements

Header: <cliext/hash_map>

Namespace: cliext

See Also

hash_multimap (STL/CLR)
hash_multimap::equal_range (STL/CLR)
hash_multimap::lower_bound (STL/CLR)
hash_multimap::upper_bound (STL/CLR)