00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined(IXE_include_unordered_map_H) && !defined(IXE_include_unordered_set_H)
00025 #warning Do not include this file directly. \
00026 It gets included by either unordered_map.h or unordered_set.h.
00027 #endif
00028
00029 #ifndef IXE_include_hash_H
00030 #define IXE_include_hash_H
00031
00038 #if defined(HAVE_STD_UNORDERED_MAP)
00039
00040 using std::hash;
00041
00042 namespace std {
00043
00044 inline size_t
00045 __stl_hash_string(const char* __s)
00046 {
00047 unsigned long __h = 0;
00048 for ( ; *__s; ++__s)
00049 __h = 5 * __h + *__s;
00050 return size_t(__h);
00051 }
00052
00053 template<>
00054 struct hash<char const*>
00055 : public std::unary_function<char const*, std::size_t>
00056 {
00057 std::size_t
00058 operator()(const char const* __s) const
00059 { return __stl_hash_string(__s); }
00060 };
00061 }
00062
00063 #elif defined(HAVE_TR1_UNORDERED_MAP)
00064
00065 using std::tr1::hash;
00066
00067 namespace std { namespace tr1 {
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 const*>
00080 : public std::unary_function<char const*, std::size_t>
00081 {
00082 std::size_t
00083 operator()(const char* __s) const
00084 { return __stl_hash_string(__s); }
00085 };
00086 }}
00087
00088 #else
00089
00090 # if defined(HAVE_EXT_HASH_MAP_SET)
00091
00092 # if __GNUC__ >= 3
00093 # define HASH_NS __gnu_cxx
00094 # else
00095 # define HASH_NS std
00096 # endif
00097 using HASH_NS::hash;
00098
00099 # elif (_MSC_VER >= 1400)
00100
00101 # define HASH_NS stdext
00102 using HASH_NS::hash;
00103
00104 # else
00105
00106 # define HASH_NS std
00107 using HASH_NS::hash;
00108 # endif
00109
00110 #include <string>
00111
00112 namespace HASH_NS {
00113 template<> struct hash<std::string>
00114 {
00115 size_t operator()(const std::string& x) const
00116 {
00117 return hash<const char*>()(x.c_str());
00118 }
00119 };
00120 }
00121 #endif
00122
00123 #endif // IXE_include_hash_H