Partager via


mappage : : nombre (STL/CLR)

Finds the number of elements matching a specified key.

    size_type count(key_type key);

Paramètres

  • key
    Key value to search for.

Notes

The member function returns the number of elements in the controlled sequence that have equivalent ordering with key. Vous l'utilisez pour déterminer le nombre d'éléments actuellement dans la séquence contrôlée qui correspondent à une clé spécifiée.

Exemple

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

Configuration requise

Header: <cliext/map>

Namespace: cliext

Voir aussi

Référence

map (STL/CLR)

mappage : : equal_range (STL/CLR)