hash_map::clear
[!UWAGA]
Ten interfejs API jest nieaktualny.Alternatywą jest unordered_map — Klasa.
Usuwa wszystkie elementy hash_map.
void clear( );
Uwagi
W Visual C++ .NET 2003, elementy członkowskie plików nagłówka <hash_map> i <hash_set> nie są już w przestrzeni nazw std, ale raczej zostały przeniesione do przestrzeni nazw stdext.Zobacz Przestrzeń nazw stdext, aby uzyskać więcej informacji.
Przykład
Podczas kompilowania w tym przykładzie z /Wp64 flagowanie lub na platformie 64-bitowej, zostanie wygenerowany kompilator ostrzeżenie C4267.Aby uzyskać więcej informacji dotyczących tego ostrzeżenia, zobacz Ostrzeżenie kompilatora (poziom 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;
}
Wymagania
Nagłówek: <hash_map>
Przestrzeń nazw: stdext