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_MAP_H // sss GNU_LIBSTDCXX_TR1_UNORDERED_MAP_
00049 #define CXXUTILS_UNORDERED_MAP_H // sss GNU_LIBSTDCXX_TR1_UNORDERED_MAP_
00050
00051 #include "CxxUtils/hashtable.h"
00052
00053
00054 #include <utility>
00055 #include <memory>
00056 #include <functional>
00057
00058
00059
00060 namespace SG
00061 {
00062 #define Internal CxxUtils_Internal // sss
00063
00064
00065
00066 template<class Key, class T,
00067 class Hash = hash<Key>,
00068 class Pred = std::equal_to<Key>,
00069 class Alloc = std::allocator<std::pair<const Key, T> >,
00070 bool cache_hash_code = false>
00071 class unordered_map
00072 : public hashtable <Key, std::pair<const Key, T>,
00073 Alloc,
00074 Internal::extract1st<std::pair<const Key, T> >, Pred,
00075 Hash, Internal::mod_range_hashing,
00076 Internal::default_ranged_hash,
00077 Internal::prime_rehash_policy,
00078 cache_hash_code, false, true>
00079 {
00080 typedef hashtable <Key, std::pair<const Key, T>,
00081 Alloc,
00082 Internal::extract1st<std::pair<const Key, T> >, Pred,
00083 Hash, Internal::mod_range_hashing,
00084 Internal::default_ranged_hash,
00085 Internal::prime_rehash_policy,
00086 cache_hash_code, false, true>
00087 Base;
00088
00089 public:
00090 typedef typename Base::size_type size_type;
00091 typedef typename Base::hasher hasher;
00092 typedef typename Base::key_equal key_equal;
00093 typedef typename Base::allocator_type allocator_type;
00094
00095 explicit
00096 unordered_map(size_type n = 10,
00097 const hasher& hf = hasher(),
00098 const key_equal& eql = key_equal(),
00099 const allocator_type& a = allocator_type())
00100 : Base(n, hf, Internal::mod_range_hashing(),
00101 Internal::default_ranged_hash(),
00102 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
00103 { }
00104
00105 template<typename InputIterator>
00106 unordered_map(InputIterator f, InputIterator l,
00107 size_type n = 10,
00108 const hasher& hf = hasher(),
00109 const key_equal& eql = key_equal(),
00110 const allocator_type& a = allocator_type())
00111 : Base (f, l, n, hf, Internal::mod_range_hashing(),
00112 Internal::default_ranged_hash(),
00113 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
00114 { }
00115 };
00116
00117 template<class Key, class T,
00118 class Hash = hash<Key>,
00119 class Pred = std::equal_to<Key>,
00120 class Alloc = std::allocator<std::pair<const Key, T> >,
00121 bool cache_hash_code = false>
00122 class unordered_multimap
00123 : public hashtable <Key, std::pair<const Key, T>,
00124 Alloc,
00125 Internal::extract1st<std::pair<const Key, T> >, Pred,
00126 Hash, Internal::mod_range_hashing,
00127 Internal::default_ranged_hash,
00128 Internal::prime_rehash_policy,
00129 cache_hash_code, false, false>
00130 {
00131 typedef hashtable <Key, std::pair<const Key, T>,
00132 Alloc,
00133 Internal::extract1st<std::pair<const Key, T> >, Pred,
00134 Hash, Internal::mod_range_hashing,
00135 Internal::default_ranged_hash,
00136 Internal::prime_rehash_policy,
00137 cache_hash_code, false, false>
00138 Base;
00139
00140 public:
00141 typedef typename Base::size_type size_type;
00142 typedef typename Base::hasher hasher;
00143 typedef typename Base::key_equal key_equal;
00144 typedef typename Base::allocator_type allocator_type;
00145
00146 explicit
00147 unordered_multimap(size_type n = 10,
00148 const hasher& hf = hasher(),
00149 const key_equal& eql = key_equal(),
00150 const allocator_type& a = allocator_type())
00151 : Base (n, hf, Internal::mod_range_hashing(),
00152 Internal::default_ranged_hash(),
00153 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
00154 { }
00155
00156
00157 template<typename InputIterator>
00158 unordered_multimap(InputIterator f, InputIterator l,
00159 typename Base::size_type n = 0,
00160 const hasher& hf = hasher(),
00161 const key_equal& eql = key_equal(),
00162 const allocator_type& a = allocator_type())
00163 : Base (f, l, n, hf, Internal::mod_range_hashing(),
00164 Internal::default_ranged_hash(),
00165 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
00166 { }
00167 };
00168
00169 template<class Key, class T, class Hash, class Pred, class Alloc,
00170 bool cache_hash_code>
00171 inline void
00172 swap(unordered_map<Key, T, Hash, Pred, Alloc, cache_hash_code>& x,
00173 unordered_map<Key, T, Hash, Pred, Alloc, cache_hash_code>& y)
00174 { x.swap(y); }
00175
00176 template<class Key, class T, class Hash, class Pred, class Alloc,
00177 bool cache_hash_code>
00178 inline void
00179 swap(unordered_multimap<Key, T, Hash, Pred, Alloc, cache_hash_code>& x,
00180 unordered_multimap<Key, T, Hash, Pred, Alloc, cache_hash_code>& y)
00181 { x.swap(y); }
00182
00183 #undef Internal // sss
00184
00185 }
00186
00187 #endif