关于hash_map的使用
Friday, 13. April 2007, 03:02:28
最重要的的hash函数的提供,看看例子就知道了:
【1】VC++2005
#include <hash_map>
using namespace stdext;
int main()
{
hash_map<string, int> hmap;
return 0;
}
【2】g++
#include <ext/hash_map>
using namespace __gnu_cxx;
// 需要自己写hash函数
struct string_hash
{
size_t operator()(const string& str) const
{
return __stl_hash_string(str.c_str());
}
};
int main()
{
hash_map<string, int, string_hash> hmap;
return 0;
}






