备注
此 API 已过时。替代为 unordered_map 类。
测试,如果 hash_map 为空。
bool empty( ) const;
返回值
true,如果 hash_map 为空;false,如果 hash_map 非空。
备注
在Visual C++ .NET 2003中,成员<hash_map> 和 <hash_set> 头文件不再在std命名空间,而是已经进入了stdext命名空间。 有关更多信息,请参见 stdext 命名空间。
示例
// hash_map_empty.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int> hm1, hm2;
typedef pair <int, int> Int_Pair;
hm1.insert ( Int_Pair ( 1, 1 ) );
if ( hm1.empty( ) )
cout << "The hash_map hm1 is empty." << endl;
else
cout << "The hash_map hm1 is not empty." << endl;
if ( hm2.empty( ) )
cout << "The hash_map hm2 is empty." << endl;
else
cout << "The hash_map hm2 is not empty." << endl;
}
要求
标头: <hash_map>
**命名空间:**stdext