Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _FUNCTIONAL_HASH_H
00031 #define _FUNCTIONAL_HASH_H 1
00032
00033 #pragma GCC system_header
00034
00035 #include <bits/c++config.h>
00036
00037 namespace std
00038 {
00039
00040
00041
00042
00043
00044
00045
00046
00047 template<typename _Result, typename _Arg>
00048 struct __hash_base
00049 {
00050 typedef _Result result_type;
00051 typedef _Arg argument_type;
00052 };
00053
00054
00055 template<typename _Tp>
00056 struct hash : public __hash_base<size_t, _Tp>
00057 {
00058 size_t
00059 operator()(_Tp __val) const;
00060 };
00061
00062
00063 template<typename _Tp>
00064 struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
00065 {
00066 size_t
00067 operator()(_Tp* __p) const
00068 { return reinterpret_cast<size_t>(__p); }
00069 };
00070
00071
00072 #define _Cxx_hashtable_define_trivial_hash(_Tp) \
00073 template<> \
00074 inline size_t \
00075 hash<_Tp>::operator()(_Tp __val) const \
00076 { return static_cast<size_t>(__val); }
00077
00078
00079 _Cxx_hashtable_define_trivial_hash(bool);
00080
00081
00082 _Cxx_hashtable_define_trivial_hash(char);
00083
00084
00085 _Cxx_hashtable_define_trivial_hash(signed char);
00086
00087
00088 _Cxx_hashtable_define_trivial_hash(unsigned char);
00089
00090
00091 _Cxx_hashtable_define_trivial_hash(wchar_t);
00092
00093
00094 _Cxx_hashtable_define_trivial_hash(char16_t);
00095
00096
00097 _Cxx_hashtable_define_trivial_hash(char32_t);
00098
00099
00100 _Cxx_hashtable_define_trivial_hash(short);
00101
00102
00103 _Cxx_hashtable_define_trivial_hash(int);
00104
00105
00106 _Cxx_hashtable_define_trivial_hash(long);
00107
00108
00109 _Cxx_hashtable_define_trivial_hash(long long);
00110
00111
00112 _Cxx_hashtable_define_trivial_hash(unsigned short);
00113
00114
00115 _Cxx_hashtable_define_trivial_hash(unsigned int);
00116
00117
00118 _Cxx_hashtable_define_trivial_hash(unsigned long);
00119
00120
00121 _Cxx_hashtable_define_trivial_hash(unsigned long long);
00122
00123 #undef _Cxx_hashtable_define_trivial_hash
00124
00125
00126
00127
00128
00129
00130 size_t
00131 _Hash_bytes(const void* __ptr, size_t __len, size_t __seed);
00132
00133
00134
00135
00136 size_t
00137 _Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed);
00138
00139 struct _Hash_impl
00140 {
00141 static size_t
00142 hash(const void* __ptr, size_t __clength,
00143 size_t __seed = static_cast<size_t>(0xc70f6907UL))
00144 { return _Hash_bytes(__ptr, __clength, __seed); }
00145
00146 template<typename _Tp>
00147 static size_t
00148 hash(const _Tp& __val)
00149 { return hash(&__val, sizeof(__val)); }
00150
00151 template<typename _Tp>
00152 static size_t
00153 __hash_combine(const _Tp& __val, size_t __hash)
00154 { return hash(&__val, sizeof(__val), __hash); }
00155 };
00156
00157 struct _Fnv_hash_impl
00158 {
00159 static size_t
00160 hash(const void* __ptr, size_t __clength,
00161 size_t __seed = static_cast<size_t>(2166136261UL))
00162 { return _Fnv_hash_bytes(__ptr, __clength, __seed); }
00163
00164 template<typename _Tp>
00165 static size_t
00166 hash(const _Tp& __val)
00167 { return hash(&__val, sizeof(__val)); }
00168
00169 template<typename _Tp>
00170 static size_t
00171 __hash_combine(const _Tp& __val, size_t __hash)
00172 { return hash(&__val, sizeof(__val), __hash); }
00173 };
00174
00175
00176 template<>
00177 inline size_t
00178 hash<float>::operator()(float __val) const
00179 {
00180
00181 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
00182 }
00183
00184
00185 template<>
00186 inline size_t
00187 hash<double>::operator()(double __val) const
00188 {
00189
00190 return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
00191 }
00192
00193
00194 template<>
00195 _GLIBCXX_PURE size_t
00196 hash<long double>::operator()(long double __val) const;
00197
00198
00199 }
00200
00201 #endif // _FUNCTIONAL_HASH_H