hash_map::clear
![]() |
---|
這個 API 已經過時。這個選項是 unordered_map Class。 |
清除 hash_map 的所有項目。
void clear( );
備註
在 Visual C++ .NET Pocket PC, <hash_map> 和 <hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。 如需詳細資訊,請參閱 stdext 命名空間。
範例
當編譯這個範例與 /Wp64 旗標或在一個獨立的平台時,編譯器警告 C4267 會產生。 如需這項警告的詳細資訊,請參閱 編譯器警告 (層級 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;
}
需求
標題: <hash_map>
命名空間: stdext