2

boost c ++ unordered_mapで使用されているハッシュ関数は何ですか?たとえば、boost::hashで使用されているハッシュアルゴリズムの種類を意味します

template <> struct hash;

ありがとう

4

2 に答える 2

9

デフォルトでは、boost::hashを使用します:)

于 2011-01-15T00:48:02.917 に答える
5

テンプレートクラスが特殊化されている場合、使用しているタイプによって異なります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*>;

独自のハッシュを 3 番目のテンプレート引数として指定することもできます。

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;
于 2011-01-15T00:47:01.540 に答える