如何在c++标准库中启用哈希
How can I enable hash in C++ Standard Library?
我试过使用#include<hash_map>
和#include <hash_set>
,我仍然得到相同的错误。
void HashTable_chaining::remove( const string & x )
{
int hash_index = hash( x, theLists.size( ) ) ;
list<string>& whichList = theLists[ hash_index ];
// search to make sure element not present
for(list<string>::iterator itr=whichList.begin();itr!=whichList.end();itr++) {
if(*itr==x) {
theLists[hash_index].erase(itr);
return;
}
}
// element not found - so nothing to remove
}
我的错误是:
Error 8 error C2872: 'hash' : ambiguous symbol c:usersaaron johnsondesktopprogram 5(johnson- noakes)program 5(johnson- noakes)chaining.cpp 32 1 Program 5(Johnson- Noakes)
有8个这样的错误。有什么建议吗?我怎样才能找出哪些头必须包括使用哈希?
是否是您自己的函数?如果是这样,请尝试将其放在您自己的名称空间中,然后调用像
这样的函数int hash_index = yournamespace::hash( x, theLists.size() );
如果你想使用std::hash:它定义在
#include <functional>
你可以在这里找到完整的c++规范,包括我们的朋友"std::hash":
http://en.cppreference.com/w/cpp/utility/hashhash_set和hash_map在SGI STL中可用。请看下面的页面:
- http://www.sgi.com/tech/stl/hash_map.html
- http://www.sgi.com/tech/stl/hash_set.html
文档和源代码可在此链接获得:
- http://www.sgi.com/tech/stl/download.html
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 使用Qt C++计算类似Git的SHA1哈希
- 如何将这个C++哈希表转换为动态扩展和收缩,而不是使用硬设置的最大值
- 用C++将哈希表写入文件并从文件中恢复
- c++找不到具有相同哈希的无序集合元素
- 哈希文件递归并保存到矢量Cryptopp中
- 对 pair<pair<int,int>pair<int,int unordered_map进行哈希处理>>
- 直接在 unordered_map 的方法中使用哈希,而不是生成哈希的用户定义对象
- 如何为字符串生成唯一但一致的 N 位哈希(小于 64 位)?
- 使用对象的基类部分模板专用化对对象进行哈希处理::哈希
- boost::包含提升单元的元组的哈希值
- 使用 Key 对 C++ 中的哈希映射进行排序. 无法排序
- C++中的并发哈希表
- 哈希映射使用 nullptr c++ 初始化节点的动态数组
- 在具有开放寻址的哈希表中插入节点 [优化逻辑]
- 与C++哈希表的基础知识混淆
- 如何为位集找到/实现一个好的哈希函数
- 对于短字符串来说,这是一个很好的哈希函数吗?
- 如何在c++标准库中启用哈希