Dela via


hash_multiset::count (STL/CLR)

Finds the number of elements matching a specified key.

    size_type count(key_type key);

Parameters

  • key
    Key value to search for.

Remarks

The member function returns the number of elements in the controlled sequence that have equivalent ordering with key. You use it to determine the number of elements currently in the controlled sequence that match a specified key.

Example

// cliext_hash_multiset_count.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("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); 
    } 
 
 a b c
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0

Requirements

Header: <cliext/hash_set>

Namespace: cliext

See Also

Reference

hash_multiset (STL/CLR)

hash_multiset::equal_range (STL/CLR)