hash_map::find (STL/CLR)

尋找符合指定之索引鍵的項目。

    iterator find(key_type key);

參數

  • Key - 索引鍵
    若要搜尋的索引鍵值。

備註

如果受控制序列中的至少一個項目具有相同的順序與key,成員函式會傳回 iterator 指定其中一個那些項目。 否則它會傳回hash_map::end (STL/CLR)()。您可以用它來目前尋找符合指定的索引鍵之受控制序列中的項目。

範例

// cliext_hash_map_find.cpp 
// compile with: /clr 
#include <cliext/hash_map> 
 
typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 
    { 
    Myhash_map c1; 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::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_map::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); 
    } 
 
  

描述

請注意, find並不保證這幾個找到的項目。

需求

標頭: < cliext/hash_map >

Namespace: cliext

請參閱

參考

hash_map (STL/CLR)

hash_map::equal_range (STL/CLR)

hash_map::lower_bound (STL/CLR)

hash_map::upper_bound (STL/CLR)