24#ifndef _ODA_HASH_SET_H_
25#define _ODA_HASH_SET_H_
43#define _GLIBCXX_PERMIT_BACKWARD_HASH
44#include <ext/hash_set>
45#define UNORDEREDSET_SUPPORTED
49#define OdUnorderedSet __gnu_cxx::hash_set
50#define OdUnorderedSet_DefaultHasher __gnu_cxx::hash
59#ifdef _STLPORT_VERSION
61#define UNORDEREDSET_SUPPORTED
62#define OdUnorderedSet std::hash_set
63#define OdUnorderedSet_DefaultHasher std::hash
65#elif defined(_MSC_VER) || defined(__BORLANDC__)
68#include <unordered_set>
69#define UNORDEREDSET_SUPPORTED
70#define OdUnorderedSet std::unordered_set
71#define OdUnorderedSet_DefaultHasher std::hash
74#define HASHSET_SUPPORTED
75#define OdUnorderedSet stdext::hash_set
78 template <
class DataType>
struct hash
80 size_t operator()(
const DataType&
x)
const {
return static_cast<size_t>(
x); }
83#define OdUnorderedSet_DefaultHasher std::hash
88#define UNORDEREDSET_SUPPORTED
89#define OdUnorderedSet std::hash_set
90#define OdUnorderedSet_DefaultHasher std::hash
96#include <rw/stdex/hashset.h>
100 template <
class DataType>
struct hash {
101 size_t operator()(
const DataType&
x)
const {
return static_cast<size_t>(
x); }
103 template <
class KeyVal,
104 class _HashFcn = hash<KeyVal>,
105 class Pred = equal_to<KeyVal>,
106 class Alloc = allocator<KeyVal> >
107 class hash_set :
public rw_hashset < KeyVal, _HashFcn, Pred, Alloc > {};
109#define UNORDEREDSET_SUPPORTED
110#define OdUnorderedSet std::hash_set
111#define OdUnorderedSet_DefaultHasher std::hash
114#define UNORDEREDSET_SUPPORTED
115#define OdUnorderedSet rw_hashset
116#define OdUnorderedSet_DefaultHasher rw_hash
122#error Unknown platform... check hash_set support
142#ifdef UNORDEREDSET_SUPPORTED
143#define HASHSET_SUPPORTED
144template <
class Key>
struct od_std_hash_set_def_func :
public OdUnorderedSet_DefaultHasher<Key>,
public std::less<Key> {};
145template <
class Key,
class _HashFcn>
146struct od_std_hash_set_generalized_equal_to :
protected _HashFcn
147{
bool operator()(
const Key& leftArg,
const Key& rightArg)
const {
148 return !_HashFcn::operator()(leftArg, rightArg) && !_HashFcn::operator()(rightArg, leftArg); } };
152template <
class Key,
class _HashFcn = od_std_hash_set_def_func<Key>,
class Alloc = std::allocator<Key> >
153class OdHashSetLs :
public OdUnorderedSet<Key, _HashFcn, od_std_hash_set_generalized_equal_to<Key, _HashFcn>, Alloc> {};
154#elif defined(_MSC_VER) || defined(__BORLANDC__)
156#if (_MSC_VER >= 1300) || defined(__BORLANDC__)
158#define HASHSET_SUPPORTED
159#define OdHashSetLs stdext::hash_set
160#define OdHashSet_DefaultHasher stdext::hash_compare
169#ifdef UNORDEREDSET_SUPPORTED
173template <
class Key,
class HashFcn = OdUnorderedSet_DefaultHasher<Key>,
class Alloc = std::allocator<Key> >
174class OdHashSet :
public OdUnorderedSet<Key, HashFcn, std::equal_to<Key>, Alloc> {};
175#elif defined(HASHSET_SUPPORTED)
176template <
class Key,
class HashFcn>
177struct od_std_hash_set_add_less_predicate :
public HashFcn,
public std::less<Key> {
178 size_t operator()(
const Key &key)
const {
return HashFcn::operator()(key); }
179 bool operator()(
const Key &ls,
const Key &rs)
const {
return std::less<Key>::operator()(ls, rs); } };
183template <
class Key,
class HashFcn = OdHashSet_DefaultHasher<Key>,
class Alloc = std::allocator<Key> >
184class OdHashSet :
public OdHashSetLs<Key, od_std_hash_set_add_less_predicate<Key, HashFcn>, Alloc> {};
189 size_t operator()(
const T* key)
const {
return OdUnorderedSet_DefaultHasher<OdIntPtr>::operator()((
OdIntPtr)key); }
size_t operator()(const T *key) const