Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __cmtkHashMapSTL_h_included_
00033 #define __cmtkHashMapSTL_h_included_
00034
00035 #include <cmtkconfig.h>
00036
00037 #define HAVE_STL_HASH_MAP
00038
00039 #if defined(__APPLE__)
00040 # include <hash_map.h>
00041 #elif defined(HAVE_UNORDERED_MAP)
00042 # include <unordered_map>
00043 #elif defined(HAVE_UNORDERED_MAP_TR1)
00044 # include <tr1/unordered_map>
00045 #elif defined(HAVE_HASH_MAP_H)
00046 # include <hash_map.h>
00047 #elif defined(HAVE_HASH_MAP)
00048 # include <hash_map>
00049 #else
00050 # undef HAVE_STL_HASH_MAP
00051 #endif
00052
00053 #ifdef __APPLE__
00054 namespace __gnu_cxx
00055 {
00056
00057 template<>
00058 struct hash<unsigned long long>
00059 {
00060 size_t
00061 operator()(unsigned long long __x) const
00062 { return (__x & 0xffff) ^ (__x >> 32 ); }
00063 };
00064
00065 }
00066 #endif // #ifdef __APPLE__
00067
00068 #ifdef HAVE_STL_HASH_MAP
00069 namespace
00070 cmtk
00071 {
00072
00073 #ifndef __APPLE__
00074
00075 template<typename TKey>
00076 struct HashFunctionInteger
00077 {
00079 size_t operator()( const TKey x ) const
00080 {
00081 return static_cast<size_t>( x );
00082 }
00083 };
00084 #endif // #ifdef __APPLE__
00085
00091 template<
00092 class TKey,
00093 class TValue,
00094 #ifndef __APPLE__
00095 class THashFunc = HashFunctionInteger<TKey>
00096 #else
00097 class THashFunc = __gnu_cxx::hash<TKey>
00098 #endif
00099 >
00100 class HashMapSTL :
00102 #if defined(__APPLE__)
00103 public __gnu_cxx::hash_map<TKey,TValue,THashFunc>
00104 #elif defined(_MSC_VER)
00105 public std::tr1::unordered_map<TKey,TValue,THashFunc>
00106 #elif defined(HAVE_UNORDERED_MAP)
00107 public std::unordered_map<TKey,TValue,THashFunc>
00108 #elif defined(HAVE_UNORDERED_MAP_TR1)
00109 public std::tr1::unordered_map<TKey,TValue,THashFunc>
00110 #elif defined(__GNUC__)
00111 public __gnu_cxx::hash_map<TKey,TValue,THashFunc>
00112 #else
00113 public std::hash_map<TKey,TValue,THashFunc>
00114 #endif
00115 {
00116 };
00117
00118 }
00119
00120 #endif // #ifdef HAVE_STL_HASH_MAP
00121 #endif // #ifndef __cmtkHashMapSTL_h_included_