boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - boost::unordered一问
相关主题
请教c++数组初始化
STL map
求大牛指导这道题。结果是什么?
c+= 怎么实现 hashtable 的?
c++0x unordered_map vs sgi hash_map
C++ 有现成的 hashtable 库吗?
问几个关于hash, map, set的问题 (转载)
弱弱的问问hash, hashtable? (转载)
请教C++中的unordered_set
INTEGER搜索求建议
相关话题的讨论汇总
话题: 哈希话题: hash话题: unordered话题: 对象话题: 函数
进入Programming版参与讨论
1 (共1页)
y**b
发帖数: 10166
1
http://www.boost.org/doc/libs/1_51_0/doc/html/unordered.html
a hash table only needs an equality function and a hash function for the key.
简言之,哈希表只需等式函数和哈希函数。
http://www.boost.org/doc/libs/1_51_0/doc/html/hash/custom.html
When writing a hash function, first look at how the equality function works.
Objects that are equal must generate the same hash value.
When objects are not equal they should generate different hash values.
简言之,写哈希函数,先参考等式函数。
相等的对象必须产生相等的哈希值;
不等的对象应该产生不同的哈希值。
我有一个unordered_set, 前面都满足,但不同的对象偶尔会产生相同的哈希值,
比如(3,100)和(5,60)是两个不同的对象,按我定义的哈希函数,3*100 = 5*60,
产生相同的哈希值。(3,100)和(5,60)能顺利插入一个unordered_set。
我想问一下:不等的对象应该产生不同的哈希值,这个要求有多严格?如果在
大量数据中出现少量的“不同的对象偶尔会产生相同的哈希值”,对性能影响
应该很小吧?
谢谢。
t****t
发帖数: 6806
2
it's not good but acceptable.

key.
works.

【在 y**b 的大作中提到】
: http://www.boost.org/doc/libs/1_51_0/doc/html/unordered.html
: a hash table only needs an equality function and a hash function for the key.
: 简言之,哈希表只需等式函数和哈希函数。
: http://www.boost.org/doc/libs/1_51_0/doc/html/hash/custom.html
: When writing a hash function, first look at how the equality function works.
: Objects that are equal must generate the same hash value.
: When objects are not equal they should generate different hash values.
: 简言之,写哈希函数,先参考等式函数。
: 相等的对象必须产生相等的哈希值;
: 不等的对象应该产生不同的哈希值。

r*********r
发帖数: 3195
3
why not use the provided hash function?
when two different objects have the same hash value, they just go
into the same bucket in the separate chaining scheme, no big deal.
1 (共1页)
进入Programming版参与讨论
相关主题
INTEGER搜索求建议
python一问
一个关于unordered_map/hashmap的问题
这个条件语句如何写?
Universal Hashing 是怎么回事?
怎样include一个函数
问一个函数对象问题
这个perl的简单小程序为什么不work? (转载)
构造函数里的异常处理
琢磨了一下c++ smart pointer,发现不能到处用
相关话题的讨论汇总
话题: 哈希话题: hash话题: unordered话题: 对象话题: 函数