hash_fun.h
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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _BACKWARD_HASH_FUN_H
00058 #define _BACKWARD_HASH_FUN_H 1
00059
00060 #include <cstddef>
00061
00062 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00063
00064 using std::size_t;
00065
00066 template<class _Key>
00067 struct hash { };
00068
00069 inline size_t
00070 __stl_hash_string(const char* __s)
00071 {
00072 unsigned long __h = 0;
00073 for ( ; *__s; ++__s)
00074 __h = 5 * __h + *__s;
00075 return size_t(__h);
00076 }
00077
00078 template<>
00079 struct hash<char*>
00080 {
00081 size_t
00082 operator()(const char* __s) const
00083 { return __stl_hash_string(__s); }
00084 };
00085
00086 template<>
00087 struct hash<const char*>
00088 {
00089 size_t
00090 operator()(const char* __s) const
00091 { return __stl_hash_string(__s); }
00092 };
00093
00094 template<>
00095 struct hash<char>
00096 {
00097 size_t
00098 operator()(char __x) const
00099 { return __x; }
00100 };
00101
00102 template<>
00103 struct hash<unsigned char>
00104 {
00105 size_t
00106 operator()(unsigned char __x) const
00107 { return __x; }
00108 };
00109
00110 template<>
00111 struct hash<signed char>
00112 {
00113 size_t
00114 operator()(unsigned char __x) const
00115 { return __x; }
00116 };
00117
00118 template<>
00119 struct hash<short>
00120 {
00121 size_t
00122 operator()(short __x) const
00123 { return __x; }
00124 };
00125
00126 template<>
00127 struct hash<unsigned short>
00128 {
00129 size_t
00130 operator()(unsigned short __x) const
00131 { return __x; }
00132 };
00133
00134 template<>
00135 struct hash<int>
00136 {
00137 size_t
00138 operator()(int __x) const
00139 { return __x; }
00140 };
00141
00142 template<>
00143 struct hash<unsigned int>
00144 {
00145 size_t
00146 operator()(unsigned int __x) const
00147 { return __x; }
00148 };
00149
00150 template<>
00151 struct hash<long>
00152 {
00153 size_t
00154 operator()(long __x) const
00155 { return __x; }
00156 };
00157
00158 template<>
00159 struct hash<unsigned long>
00160 {
00161 size_t
00162 operator()(unsigned long __x) const
00163 { return __x; }
00164 };
00165
00166 _GLIBCXX_END_NAMESPACE
00167
00168 #endif