Condividi tramite


map::size

Restituisce il numero di elementi nella mappa.

size_type size( ) const;

Valore restituito

La lunghezza del mapping.

Esempio

Nel compilare l'esempio con il flag /Wp64 o su una piattaforma a 64 bit, di avviso del compilatore l'avviso C4267 viene generato.Per ulteriori informazioni su questo problema, vedere Avviso del compilatore (livello 3) C4267.

// map_size.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main()
{
    using namespace std;
    map<int, int> m1, m2;
    map<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

    m1.insert(Int_Pair(1, 1));
    i = m1.size();
    cout << "The map length is " << i << "." << endl;

    m1.insert(Int_Pair(2, 4));
    i = m1.size();
    cout << "The map length is now " << i << "." << endl;
}
  
  

Requisiti

intestazione: <map>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

map Class

map::max_size, map::clear, map::erase, e map::size

Libreria di modelli standard