icn*_*icn 2 c++ hash boost hash-function
boost c ++ unordered_map正在使用什么哈希函数?我的意思是boost :: hash正在使用什么样的哈希算法
template <> struct hash;
谢谢
这取决于你所使用的类型,如果你看看这里的boost::hash模板类是专业化:
template<> struct hash<bool>;
template<> struct hash<char>;
template<> struct hash<signed char>;
template<> struct hash<unsigned char>;
template<> struct hash<wchar_t>;
template<> struct hash<short>;
template<> struct hash<unsigned short>;
template<> struct hash<int>;
template<> struct hash<unsigned int>;
template<> struct hash<long>;
template<> struct hash<unsigned long>;
template<> struct hash<long long>;
template<> struct hash<unsigned long long>;
template<> struct hash<float>;
template<> struct hash<double>;
template<> struct hash<long double>;
template<> struct hash<std::string>;
template<> struct hash<std::wstring>;
template<typename T> struct hash<T*>;
Run Code Online (Sandbox Code Playgroud)
您还可以将自己的哈希指定为第三个模板参数:
namespace boost {
template<typename Key, typename Mapped, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>,
typename Alloc = std::allocator<std::pair<Key const, Mapped> > >
class unordered_map;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |