簡體   English   中英

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

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

boost c ++ unordered_map正在使用什么哈希函數? 我的意思是boost :: hash正在使用什么樣的哈希算法

template <> struct hash;

謝謝

默認情況下,它使用boost :: 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*>;

您還可以將自己的哈希指定為第三個模板參數:

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