6 #ifdef HAVE_TR1_UNORDERED_MAP
8 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
9 #undef HAVE_TR1_UNORDERED_MAP
14 #ifdef HAVE_TR1_UNORDERED_MAP
15 #define vsUMap std::tr1::unordered_map
16 #define vsHashComp std::tr1::hash_compare
17 #define vsHash std::tr1::hash
19 #define vsUMap stdext::hash_map
20 #define vsHashComp stdext::hash_compare
21 #define vsHash stdext::hash
25 #ifdef HAVE_TR1_UNORDERED_MAP
26 #if defined(_MSC_VER) && _MSC_VER >= 1600
27 #include <unordered_map>
29 #include <tr1/unordered_map>
34 #else //#ifdef _WIN32 { ... } else ...
41 template <
class Key,
class Traits = std::less< Key > >
51 #else //if __GNUC__ == 2 { ... } else ...
52 #ifdef HAVE_TR1_UNORDERED_MAP
53 #include <tr1/unordered_map>
60 #else //if HAVE_TR1_UNORDERED_MAP { ... } else ...
61 #include <ext/hash_map>
62 #define stdext __gnu_cxx
70 class hash< std::string >
75 size_t _HASH_INTSIZE = (
sizeof (size_t)*8);
76 size_t _HASH_SALT_0 = 0x7EF92C3B;
77 size_t _HASH_SALT_1 = 0x9B;
79 for (std::string::const_iterator start = key.begin(); start != key.end(); start++) {
80 k ^= (*start&_HASH_SALT_1);
82 k = ( ( (k>>4)&0xF )|( k<<(_HASH_INTSIZE-4) ) );
88 #endif //if HAVE_TR1_UNORDERED_MAP { ... } else ...
97 return a( (
size_t) key );
101 class hash< const void* >
107 return a( (
size_t) key );
111 class hash< const Unit* >
117 return a( (
size_t) key>>4 );
121 class hash< std::pair< Unit*, Unit* > >
125 size_t operator()(
const std::pair< Unit*, Unit* > &key )
const
127 return (
size_t) (size_t) ( a( (
int) ( ( (
size_t) key.first )>>4 ) )
128 ^a( (
int) ( ( (
size_t) key.second )>>4 ) ) );
132 template <
class Key,
class Traits = std::less< Key > >
136 static const size_t bucket_size = 4;
137 static const size_t min_buckets = 8;
140 #ifdef HAVE_TR1_UNORDERED_MAP
144 #endif //if __GNUC__ == 2 { ... } else ...
145 #endif //#ifdef _WIN32 { ... } else ...
146 #endif //def _GNUHASH_H_