hash_map::clear

HinweisHinweis

Diese API ist veraltet.Die Alternative ist unordered_map Class.

Löscht alle Elemente eines hash_map.

void clear( );

Hinweise

In Visual C++ .NET 2003, sind Member der <hash_map> und <hash_set> Headerdateien nicht mehr im stdnamespace, sondern sind in den stdext Namespace verschoben wurde.Weitere Informationen finden Sie unter Der stdext-Namespace.

Beispiel

Wenn Sie dieses Beispiel mit dem /Wp64 - oder auf einer 64-Bit-Plattform kompiliert, Compilerwarnung wird C4267 generiert.Weitere Informationen über diese Warnung, finden Sie unter Compilerwarnung (Stufe 3) C4267.

// hash_map_clear.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
    using namespace std;
    using namespace stdext;
    hash_map<int, int> hm1;
    hash_map<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

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

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

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

Anforderungen

Header: <hash_map>

Namespace: stdext

Siehe auch

Referenz

hash_map Class

Standardvorlagenbibliothek