Udostępnij za pośrednictwem


map::clear

Usuwa wszystkie elementy mapy.

void clear( );

Przykład

Podczas kompilowania przykładzie z /Wp64 flagę lub na platformie 64-bitowe, zostanie wygenerowany kompilator ostrzeżenia C4267.Ostrzeżenie to uzyskać więcej informacji, zobacz Kompilator ostrzeżenia (poziom 3) C4267.

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

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

    m1.insert(Int_Pair(1, 1));
    m1.insert(Int_Pair(2, 4));

    i = m1.size();
    cout << "The size of the map is initially "
         << i << "." << endl;

    m1.clear();
    i = m1.size();
    cout << "The size of the map after clearing is "
         << i << "." << endl;
}
  
  

Wymagania

Nagłówek: <map>

Obszar nazw: std

Zobacz też

Informacje

map Class

map::max_size, map::clear, map::erase, i map::size

Standardowa biblioteka szablonu