24#ifndef _ODA_HASH_MAP_H_
25#define _ODA_HASH_MAP_H_
43#define _GLIBCXX_PERMIT_BACKWARD_HASH
44#include <ext/hash_map>
45#define UNORDEREDMAP_SUPPORTED
49#define OdUnorderedMap __gnu_cxx::hash_map
50#define OdUnorderedMap_DefaultHasher __gnu_cxx::hash
52#if OD_SIZEOF_LONG == 4
57 size_t operator()(
const OdUInt64& handle)
const {
return handle; }
69#ifdef _STLPORT_VERSION
71#define UNORDEREDMAP_SUPPORTED
72#define OdUnorderedMap std::hash_map
73#define OdUnorderedMap_DefaultHasher std::hash
75#elif defined(_MSC_VER) || defined(__BORLANDC__)
78#include <unordered_map>
79#define UNORDEREDMAP_SUPPORTED
80#define OdUnorderedMap std::unordered_map
81#define OdUnorderedMap_DefaultHasher std::hash
86#define UNORDEREDMAP_SUPPORTED
87#define OdUnorderedMap std::hash_map
88#define OdUnorderedMap_DefaultHasher std::hash
94#include <rw/stdex/hashmap.h>
98 template <
class DataType>
struct hash {
99 size_t operator()(
const DataType&
x)
const {
return static_cast<size_t>(
x); }
101 template <
class KeyVal,
103 class _HashFcn = hash<KeyVal>,
104 class Pred = equal_to<KeyVal>,
105 class Alloc = allocator <pair <const KeyVal, Value> > >
106 class hash_map :
public rw_hashmap < KeyVal, Value, _HashFcn, Pred, Alloc > { };
108#define UNORDEREDMAP_SUPPORTED
109#define OdUnorderedMap std::hash_map
110#define OdUnorderedMap_DefaultHasher std::hash
113#define UNORDEREDMAP_SUPPORTED
114#define OdUnorderedMap rw_hashmap
115#define OdUnorderedMap_DefaultHasher rw_hash
121#error Unknown platform... check hash_map support
141#ifdef UNORDEREDMAP_SUPPORTED
142#define HASHMAP_SUPPORTED
143template <
class Key>
struct od_std_hash_map_def_func :
public OdUnorderedMap_DefaultHasher<Key>,
public std::less<Key> {};
144template <
class Key,
class _HashFcn>
145struct od_std_hash_map_generalized_equal_to :
protected _HashFcn
146{
bool operator()(
const Key& leftArg,
const Key& rightArg)
const {
147 return !_HashFcn::operator()(leftArg, rightArg) && !_HashFcn::operator()(rightArg, leftArg); } };
152template <
class Key,
class Value,
class _HashFcn = od_std_hash_map_def_func<Key>,
class Alloc = std::allocator<std::pair<const Key, Value> > >
153class OdHashMapLs :
public OdUnorderedMap<Key, Value, _HashFcn, od_std_hash_map_generalized_equal_to<Key, _HashFcn>, Alloc> {};
154#elif defined(_MSC_VER) || defined(__BORLANDC__)
156#if (_MSC_VER >= 1300) || defined(__BORLANDC__)
158#define HASHMAP_SUPPORTED
159#define OdHashMapLs stdext::hash_map
160#define OdHashMap_DefaultHasher stdext::hash_compare
169#ifdef UNORDEREDMAP_SUPPORTED
173template <
class Key,
class Value,
class HashFcn = OdUnorderedMap_DefaultHasher<Key>,
class Alloc = std::allocator<std::pair<const Key, Value> > >
174class OdHashMap :
public OdUnorderedMap<Key, Value, HashFcn, std::equal_to<Key>, Alloc> {};
175#elif defined(HASHMAP_SUPPORTED)
176template <
class Key,
class HashFcn>
177struct od_std_hash_map_add_less_predicate :
public HashFcn,
public std::less<Key> {
183 size_t operator()(
const Key &key)
const {
return HashFcn::operator()(key); }
184 bool operator()(
const Key &ls,
const Key &rs)
const {
return std::less<Key>::operator()(ls, rs); } };
188template <
class Key,
class Value,
class HashFcn = OdHashMap_DefaultHasher<Key>,
class Alloc = std::allocator<std::pair<const Key, Value> > >
189class OdHashMap :
public OdHashMapLs<Key, Value, od_std_hash_map_add_less_predicate<Key, HashFcn>, Alloc> {};