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 wpl { namespace tool {
00031 # define WP_HASH_NAMESPACE_END } }
00032
00033 namespace wpl
00034 {
00035 namespace tool
00036 {
00037 template <class T>
00038 struct hash
00039 {
00040 };
00041 }
00042 }
00043
00044 # else // ! WP_DONT_USE_HASH
00045
00046 # ifdef __GNUC__ // GCC
00047
00048 # if __GNUC__ < 3 // GCC < 3.0
00049 # include <hash_set.h>
00050 # include <hash_map.h>
00051
00052 # define WP_HASH_NAMESPACE_BEGIN
00053 # define WP_HASH_NAMESPACE_END
00054
00055 namespace wpl
00056 {
00057 namespace tool
00058 {
00059 using ::hash_map;
00060 using ::hash_set;
00061 }
00062 }
00063
00064
00065 # elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
00066 # include <ext/hash_set>
00067 # include <ext/hash_map>
00068
00069
00070 # if __GNUC__ == 3 && __GNUC_MINOR__ == 0
00071
00072 # define WP_HASH_NAMESPACE_BEGIN namespace std {
00073 # define WP_HASH_NAMESPACE_END }
00074
00075 namespace wpl
00076 {
00077 namespace tool
00078 {
00079 using ::std::hash_map;
00080 using ::std::hash_set;
00081 }
00082 }
00083
00084 # else // 3.1 <= GCC < 4.3
00085
00086 # define WP_HASH_NAMESPACE_BEGIN namespace __gnu_cxx {
00087 # define WP_HASH_NAMESPACE_END }
00088
00089 namespace wpl
00090 {
00091 namespace tool
00092 {
00093 using ::__gnu_cxx::hash_map;
00094 using ::__gnu_cxx::hash_set;
00095 }
00096 }
00097
00098 # endif // __GNUC__ == 3 && __GNUC_MINOR__ == 0
00099
00100 # else // GCC >= 4.3
00101 # include <tr1/unordered_set>
00102 # include <tr1/unordered_map>
00103
00104 # define WP_HASH_NAMESPACE_BEGIN namespace std { namespace tr1 {
00105 # define WP_HASH_NAMESPACE_END } }
00106
00107 namespace wpl
00108 {
00109 namespace tool
00110 {
00111 template <class T>
00112 struct hash_set: public std::tr1::unordered_set<T>
00113 {
00114 hash_set()
00115 {
00116 }
00117
00118 hash_set(size_t n): std::tr1::unordered_set<T>(n)
00119 {
00120 }
00121 };
00122
00123 template <class K, class T>
00124 struct hash_map: public std::tr1::unordered_map<K, T>
00125 {
00126 };
00127 }
00128 }
00129
00130 # endif // ! __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
00131
00132 # else // ! __GNUC__ // ... There are other compilers, right?
00133
00134 # include <hash_set>
00135 # include <hash_map>
00136
00137 # define WP_HASH_NAMESPACE_BEGIN namespace std {
00138 # define WP_HASH_NAMESPACE_END }
00139
00140 namespace wpl
00141 {
00142 namespace tool
00143 {
00144 using ::std::hash_map;
00145 using ::std::hash_set;
00146 }
00147 }
00148
00149 # endif // __GNUC__
00150 # endif // WP_DONT_USE_HASH
00151
00152 #endif // ! TOOL_HASH_HH_