我想使用类似于.NET哈希集的数据结构,我尝试使用无序的哈希集和默认的哈希方法和自定义比较器,如下所示:
struct comparer
{
bool operator()( const TCHAR* first,const TCHAR* second) const
{
return _tcscmp((TCHAR*)first,(TCHAR*)second) == 0;
}
};
typedef unordered_set<const TCHAR*,hash<const TCHAR*>,comparer> HashSet;
问题是当我试图使用hashtset查找特定的密钥时(使用
find
方法)我刚刚用
insert
它返回
HashSet::end()
!!
你能解释一下问题是什么吗?
我正在使用VS2010下的VC++