00001
00002
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef CXXUTILS_UNORDERED_SET_H // sss GNU_LIBSTDCXX_TR1_UNORDERED_SET_
00049 #define CXXUTILS_UNORDERED_SET_H // sss GNU_LIBSTDCXX_TR1_UNORDERED_SET_
00050
00051 #include "CxxUtils/hashtable.h"
00052
00053 #include <memory>
00054 #include <functional>
00055
00056
00057
00058 namespace SG
00059 {
00060 #define Internal CxxUtils_Internal // sss
00061
00062
00063
00064
00065 template<class Value,
00066 class Hash = hash<Value>,
00067 class Pred = std::equal_to<Value>,
00068 class Alloc = std::allocator<Value>,
00069 bool cache_hash_code = false>
00070 class unordered_set
00071 : public hashtable<Value, Value, Alloc,
00072 Internal::identity<Value>, Pred,
00073 Hash, Internal::mod_range_hashing,
00074 Internal::default_ranged_hash,
00075 Internal::prime_rehash_policy,
00076 cache_hash_code, true, true>
00077 {
00078 typedef hashtable<Value, Value, Alloc,
00079 Internal::identity<Value>, Pred,
00080 Hash, Internal::mod_range_hashing,
00081 Internal::default_ranged_hash,
00082 Internal::prime_rehash_policy,
00083 cache_hash_code, true, true>
00084 Base;
00085
00086 public:
00087 typedef typename Base::size_type size_type;
00088 typedef typename Base::hasher hasher;
00089 typedef typename Base::key_equal key_equal;
00090 typedef typename Base::allocator_type allocator_type;
00091
00092 explicit
00093 unordered_set(size_type n = 10,
00094 const hasher& hf = hasher(),
00095 const key_equal& eql = key_equal(),
00096 const allocator_type& a = allocator_type())
00097 : Base (n, hf, Internal::mod_range_hashing(),
00098 Internal::default_ranged_hash(),
00099 eql, Internal::identity<Value>(), a)
00100 { }
00101
00102 template<typename InputIterator>
00103 unordered_set(InputIterator f, InputIterator l,
00104 size_type n = 10,
00105 const hasher& hf = hasher(),
00106 const key_equal& eql = key_equal(),
00107 const allocator_type& a = allocator_type())
00108 : Base (f, l, n, hf, Internal::mod_range_hashing(),
00109 Internal::default_ranged_hash(),
00110 eql, Internal::identity<Value>(), a)
00111 { }
00112 };
00113
00114 template<class Value,
00115 class Hash = hash<Value>,
00116 class Pred = std::equal_to<Value>,
00117 class Alloc = std::allocator<Value>,
00118 bool cache_hash_code = false>
00119 class unordered_multiset
00120 : public hashtable <Value, Value, Alloc,
00121 Internal::identity<Value>, Pred,
00122 Hash, Internal::mod_range_hashing,
00123 Internal::default_ranged_hash,
00124 Internal::prime_rehash_policy,
00125 cache_hash_code, true, false>
00126 {
00127 typedef hashtable<Value, Value, Alloc,
00128 Internal::identity<Value>, Pred,
00129 Hash, Internal::mod_range_hashing,
00130 Internal::default_ranged_hash,
00131 Internal::prime_rehash_policy,
00132 cache_hash_code, true, false>
00133 Base;
00134
00135 public:
00136 typedef typename Base::size_type size_type;
00137 typedef typename Base::hasher hasher;
00138 typedef typename Base::key_equal key_equal;
00139 typedef typename Base::allocator_type allocator_type;
00140
00141 explicit
00142 unordered_multiset(size_type n = 10,
00143 const hasher& hf = hasher(),
00144 const key_equal& eql = key_equal(),
00145 const allocator_type& a = allocator_type())
00146 : Base (n, hf, Internal::mod_range_hashing(),
00147 Internal::default_ranged_hash(),
00148 eql, Internal::identity<Value>(), a)
00149 { }
00150
00151
00152 template<typename InputIterator>
00153 unordered_multiset(InputIterator f, InputIterator l,
00154 typename Base::size_type n = 0,
00155 const hasher& hf = hasher(),
00156 const key_equal& eql = key_equal(),
00157 const allocator_type& a = allocator_type())
00158 : Base (f, l, n, hf, Internal::mod_range_hashing(),
00159 Internal::default_ranged_hash(), eql,
00160 Internal::identity<Value>(), a)
00161 { }
00162 };
00163
00164 template<class Value, class Hash, class Pred, class Alloc,
00165 bool cache_hash_code>
00166 inline void
00167 swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
00168 unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
00169 { x.swap(y); }
00170
00171 template<class Value, class Hash, class Pred, class Alloc,
00172 bool cache_hash_code>
00173 inline void
00174 swap(unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
00175 unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
00176 { x.swap(y); }
00177
00178 #undef Internal // sss
00179
00180 }
00181
00182 #endif