00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_HASH_HH_
00023 # define TOOL_HASH_HH_
00024
00025 # ifdef WP_DONT_USE_HASH
00026
00027 # include <set>
00028 # include <map>
00029
00030 # define WP_HASH_NAMESPACE_BEGIN namespace tool {
00031 # define WP_HASH_NAMESPACE_END }
00032
00033 namespace tool
00034 {
00035 template <class T>
00036 struct hash
00037 {
00038 };
00039 }
00040
00041 # else // ! WP_DONT_USE_HASH
00042
00043 # ifdef __GNUC__ // GCC
00044
00045 # if __GNUC__ < 3 // GCC < 3.0
00046 # include <hash_set.h>
00047 # include <hash_map.h>
00048
00049 # define WP_HASH_NAMESPACE_BEGIN
00050 # define WP_HASH_NAMESPACE_END
00051
00052 namespace tool
00053 {
00054 using ::hash_map;
00055 using ::hash_set;
00056 }
00057
00058
00059 # elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
00060 # include <ext/hash_set>
00061 # include <ext/hash_map>
00062
00063
00064 # if __GNUC__ == 3 && __GNUC_MINOR__ == 0
00065
00066 # define WP_HASH_NAMESPACE_BEGIN namespace std {
00067 # define WP_HASH_NAMESPACE_END }
00068
00069 namespace tool
00070 {
00071 using ::std::hash_map;
00072 using ::std::hash_set;
00073 }
00074
00075 # else // 3.1 <= GCC < 4.3
00076
00077 # define WP_HASH_NAMESPACE_BEGIN namespace __gnu_cxx {
00078 # define WP_HASH_NAMESPACE_END }
00079
00080 namespace tool
00081 {
00082 using ::__gnu_cxx::hash_map;
00083 using ::__gnu_cxx::hash_set;
00084 }
00085
00086 # endif // __GNUC__ == 3 && __GNUC_MINOR__ == 0
00087
00088 # else // GCC >= 4.3
00089 # include <tr1/unordered_set>
00090 # include <tr1/unordered_map>
00091
00092 # define WP_HASH_NAMESPACE_BEGIN namespace std { namespace tr1 {
00093 # define WP_HASH_NAMESPACE_END } }
00094
00095 namespace tool
00096 {
00097 template <class T>
00098 struct hash_set: public std::tr1::unordered_set<T>
00099 {
00100 hash_set()
00101 {
00102 }
00103
00104 hash_set(size_t n): std::tr1::unordered_set<T>(n)
00105 {
00106 }
00107 };
00108
00109 template <class K, class T>
00110 struct hash_map: public std::tr1::unordered_map<K, T>
00111 {
00112 };
00113 }
00114
00115 # endif // ! __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
00116
00117 # else // ! __GNUC__ // ... There are other compilers, right?
00118
00119 # include <hash_set>
00120 # include <hash_map>
00121
00122 # define WP_HASH_NAMESPACE_BEGIN namespace std {
00123 # define WP_HASH_NAMESPACE_END }
00124
00125 namespace tool
00126 {
00127 using ::std::hash_map;
00128 using ::std::hash_set;
00129 }
00130
00131 # endif // __GNUC__
00132 # endif // WP_DONT_USE_HASH
00133
00134 #endif // ! TOOL_HASH_HH_