简体   繁体   English

boost c ++ unordered_map正在使用什么哈希函数?

[英]what hash function is being used by boost c++ unordered_map?

what hash function is being used by boost c++ unordered_map ? boost c ++ unordered_map正在使用什么哈希函数? I meant what kind of hash algorithms being used by boost::hash, for example 我的意思是boost :: hash正在使用什么样的哈希算法

template<> struct hash; template <> struct hash;

Thanks 谢谢

默认情况下,它使用boost :: hash :)

It depends on the type you are using, if you look here the boost::hash template class is specialised: 这取决于你使用的类型,如果你看这里 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*>;

You can also specify your own hash as the third template argument: 您还可以将自己的哈希指定为第三个模板参数:

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM