std::
unordered_multimap::rehash
公众成员函数 <unordered_map>
hasher hash_function() const;
获取哈希函数
返回
unordered_multimap容器使用的哈希函数对象。
哈希函数是一个一元函数,它接受一个类型为
key_type的对象作为参数,
并基于该对象返回一个类型为
size_t的唯一值。它被容器在构造时采用
(参阅
unordered_multimap的构造函数了解更多信息)。
缺省情况下,它是对应键类型的缺省哈希函数:
hash<key_type>。
☲ 参数
-
none
☉ 返回值
hash函数.成员类型
hasher是容器使用的
hasher函数的类型,
在
unordered_multimap中定义为其第三个模板形参(hash)的别名。
☣ 示例
// unordered_multimap::hash_function
#include <iostream>
#include <string>
#include <unordered_map>
typedef std::unordered_multimap<std::string,std::string> stringmap;
int main ()
{
stringmap myumm;
stringmap::hasher fn = myumm.hash_function();
std::cout << "this: " << fn ("this") << std::endl;
std::cout << "thin: " << fn ("thin") << std::endl;
return 0;
}
|
可能输出:
this: 671344778
thin: 3223852919
请注意,两个相似的字符串如何产生完全不同的哈希值。
✥ 复杂度
常量
☣ 迭代器的有效性
不变
🍄 另请参阅
unordered_multimap::key_eq |
获取键的等价谓词(公众成员函数) |
unordered_multimap::get_allocator |
获取分配器(公众成员函数) |