34 #if defined(_MSC_VER) && (_MSC_VER > 1500)
35 # define TLP_USE_UNORDERED_MAP
36 #elif defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
37 # define TLP_USE_UNORDERED_MAP
40 #ifdef TLP_USE_UNORDERED_MAP
41 # include <unordered_map>
42 # include <unordered_set>
43 # define TLP_HASH_MAP std::unordered_map
44 # define TLP_HASH_SET std::unordered_set
45 # define TLP_BEGIN_HASH_NAMESPACE namespace std
46 # define TLP_END_HASH_NAMESPACE
48 #elif (! defined _MSC_VER && (__GNUC__ < 4 || __GNUC_MINOR__ < 1))
49 # include <tulip/tulipconf.h>
54 # include <ext/hash_map>
55 # include <ext/hash_set>
57 # define TLP_HASH_MAP stdext::hash_map
58 # define TLP_HASH_SET stdext::hash_set
59 # define TLP_BEGIN_HASH_NAMESPACE namespace stdext
60 # define TLP_END_HASH_NAMESPACE
65 template<>
struct hash<const std::string> {
66 size_t operator()(
const std::string &s)
const {
67 return hash<const char *>()(s.c_str());
70 template<>
struct hash<std::string> {
71 size_t operator()(
const std::string &s)
const {
72 return hash<const char *>()(s.c_str());
77 size_t operator()(
const double s)
const {
83 size_t operator()(
const float s)
const {
84 return hash<unsigned int>()(*((
unsigned int *) &s));
90 # include <tr1/unordered_map>
91 # include <tr1/unordered_set>
92 # define TLP_HASH_MAP std::tr1::unordered_map
93 # define TLP_HASH_SET std::tr1::unordered_set
94 # define TLP_BEGIN_HASH_NAMESPACE namespace std { namespace tr1
95 # define TLP_END_HASH_NAMESPACE }
107 TLP_BEGIN_HASH_NAMESPACE {
109 inline void hash_combine(std::size_t & seed,
const T & v) {
111 seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
113 } TLP_END_HASH_NAMESPACE