hash_map::count (STL/CLR)

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

    size_type count(key_type key);

參數

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

備註

成員函式會傳回具有與對等排序受控制序列中的元素數目key。您會用它來判斷目前在受控制序列中,符合指定之索引鍵的項目數目。

範例

// cliext_hash_map_count.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("count(L'A') = {0}", c1.count(L'A')); 
    System::Console::WriteLine("count(L'b') = {0}", c1.count(L'b')); 
    System::Console::WriteLine("count(L'C') = {0}", c1.count(L'C')); 
    return (0); 
    } 
 
  

需求

標頭: < cliext/hash_map >

Namespace: cliext

請參閱

參考

hash_map (STL/CLR)

hash_map::equal_range (STL/CLR)