我想使用类似服务净HashSet的数据结构,我试图用默认的散列法和自定义比较使用unordered_set如下:TCHAR *要求的无序集?
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()
!
你能解释一下是什么问题? 我使用VC++ VS2010
下
为什么你需要抛弃`_tcscmp()`的常量?这不应该是必要的。 – Rup 2010-11-25 13:38:34
不知情的猜测:`hash <>`是散列指针值而不是字符串。但我不知道TR1班。 – Rup 2010-11-25 13:39:29