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