00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _HASH_UTILS_H_
00020 #define _HASH_UTILS_H_
00021
00022 #include "exult_types.h"
00023
00024 #ifdef DONT_HAVE_HASH_MAP
00025 # include <map>
00026 #else
00027 #if HAVE_EXT_HASH_MAP
00028 # include <ext/hash_map>
00029 # if (defined(__GNUC__) && (__GNUC__ >= 3) && ( __GNUC_MINOR__ >= 0))
00030 using __gnu_cxx::hash_map;
00031 # else
00032 using std::hash_map;
00033 # endif
00034 #else
00035 # include <hash_map>
00036 #endif
00037 # ifdef MACOS
00038 using Metrowerks::hash_map;
00039 # endif
00040 #endif
00041
00042 #ifdef DONT_HAVE_HASH_SET
00043 # include <set>
00044 #else
00045 #if HAVE_EXT_HASH_SET
00046 # include <ext/hash_set>
00047 # if (defined(__GNUC__) && (__GNUC__ >= 3) && ( __GNUC_MINOR__ >= 0))
00048 using __gnu_cxx::hash_set;
00049 # else
00050 using std::hash_set;
00051 # endif
00052 #else
00053 # include <hash_set>
00054 #endif
00055 # ifdef MACOS
00056 using Metrowerks::hash_set;
00057 # endif
00058 #endif
00059
00060
00061 #if defined(DONT_HAVE_HASH_MAP) && defined(DONT_HAVE_HASH_SET)
00062
00063
00064
00065
00066 struct ltstr {
00067 bool operator()(const char* s1, const char* s2) const {
00068 return (std::strcmp(s1, s2) < 0);
00069 }
00070 };
00071
00072 #else
00073
00074
00075
00076
00077 struct hashstr
00078 {
00079 long operator() (const char *str) const
00080 {
00081 const uint32 m = 4294967291u;
00082 uint32 result = 0;
00083 for (; *str != '\0'; ++str)
00084 result = ((result << 8) + *str) % m;
00085 return long(result);
00086 }
00087 };
00088
00089
00090
00091
00092 struct eqstr
00093 {
00094 bool operator()(const char* s1, const char* s2) const {
00095 return std::strcmp(s1, s2) == 0;
00096 }
00097 };
00098
00099 #endif
00100
00101 #endif