24 #ifndef __TBB_concurrent_unordered_map_H 25 #define __TBB_concurrent_unordered_map_H 27 #include "internal/_concurrent_unordered_impl.h" 32 namespace interface5 {
35 template<
typename Key,
typename T,
typename Hash_compare,
typename Allocator,
bool Allow_multimapping>
39 typedef std::pair<const Key, T> value_type;
41 typedef Hash_compare hash_compare;
42 typedef typename Allocator::template rebind<value_type>::other allocator_type;
43 enum { allow_multimapping = Allow_multimapping };
48 class value_compare :
public std::binary_function<value_type, value_type, bool>
53 bool operator()(
const value_type& left,
const value_type& right)
const 55 return (my_hash_compare(left.first, right.first));
58 value_compare(
const hash_compare& comparator) : my_hash_compare(comparator) {}
61 hash_compare my_hash_compare;
64 template<
class Type1,
class Type2>
65 static const Key& get_key(
const std::pair<Type1, Type2>& value) {
69 hash_compare my_hash_compare;
72 template <
typename Key,
typename T,
typename Hasher = tbb::tbb_hash<Key>,
typename Key_equality = std::equal_to<Key>,
73 typename Allocator = tbb::tbb_allocator<std::pair<const Key, T> > >
75 public internal::concurrent_unordered_base< concurrent_unordered_map_traits<Key, T,
76 internal::hash_compare<Key, Hasher, Key_equality>, Allocator, false> >
81 typedef internal::concurrent_unordered_base< traits_type > base_type;
85 using traits_type::allow_multimapping;
88 using base_type::find;
89 using base_type::insert;
93 typedef typename base_type::value_type value_type;
94 typedef T mapped_type;
95 typedef Hasher hasher;
96 typedef Key_equality key_equal;
99 typedef typename base_type::allocator_type allocator_type;
100 typedef typename base_type::pointer pointer;
101 typedef typename base_type::const_pointer const_pointer;
102 typedef typename base_type::reference reference;
103 typedef typename base_type::const_reference const_reference;
105 typedef typename base_type::size_type size_type;
106 typedef typename base_type::difference_type difference_type;
108 typedef typename base_type::iterator iterator;
109 typedef typename base_type::const_iterator const_iterator;
110 typedef typename base_type::iterator local_iterator;
111 typedef typename base_type::const_iterator const_local_iterator;
115 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
116 const allocator_type& a = allocator_type())
117 : base_type(n_of_buckets, key_compare(_Hasher, _Key_equality), a)
125 template <
typename Iterator>
127 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
128 const allocator_type& a = allocator_type())
129 : base_type(n_of_buckets, key_compare(_Hasher, _Key_equality), a)
134 #if __TBB_INITIALIZER_LISTS_PRESENT 135 concurrent_unordered_map(std::initializer_list<value_type> il, size_type n_of_buckets = base_type::initial_bucket_number,
137 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
138 const allocator_type& a = allocator_type())
139 : base_type(n_of_buckets, key_compare(_Hasher, _Key_equality), a)
141 this->insert(il.begin(),il.end());
143 #endif //# __TBB_INITIALIZER_LISTS_PRESENT 145 #if __TBB_CPP11_IMPLICIT_MOVE_MEMBERS_GENERATION_BROKEN 151 concurrent_unordered_map& operator=(
const concurrent_unordered_map& table)
153 return static_cast<concurrent_unordered_map&
>(base_type::operator=(table));
156 concurrent_unordered_map(concurrent_unordered_map&& table)
157 : base_type(std::move(table))
161 concurrent_unordered_map& operator=(concurrent_unordered_map&& table)
163 return static_cast<concurrent_unordered_map&
>(base_type::operator=(std::move(table)));
165 #endif //__TBB_CPP11_IMPLICIT_MOVE_MEMBERS_GENERATION_BROKEN 167 concurrent_unordered_map(
const concurrent_unordered_map& table,
const Allocator& a)
168 : base_type(table, a)
172 #if __TBB_CPP11_RVALUE_REF_PRESENT 173 concurrent_unordered_map(concurrent_unordered_map&& table,
const Allocator& a) : base_type(std::move(table), a)
178 mapped_type& operator[](
const key_type& key)
180 iterator where = find(key);
184 where = insert(std::pair<key_type, mapped_type>(key, mapped_type())).first;
187 return ((*where).second);
190 mapped_type& at(
const key_type& key)
192 iterator where = find(key);
196 tbb::internal::throw_exception(tbb::internal::eid_invalid_key);
199 return ((*where).second);
202 const mapped_type& at(
const key_type& key)
const 204 const_iterator where = find(key);
208 tbb::internal::throw_exception(tbb::internal::eid_invalid_key);
211 return ((*where).second);
215 template <
typename Key,
typename T,
typename Hasher = tbb::tbb_hash<Key>,
typename Key_equality = std::equal_to<Key>,
216 typename Allocator = tbb::tbb_allocator<std::pair<const Key, T> > >
218 public internal::concurrent_unordered_base< concurrent_unordered_map_traits< Key, T,
219 internal::hash_compare<Key, Hasher, Key_equality>, Allocator, true> >
224 typedef internal::concurrent_unordered_base<traits_type> base_type;
225 #if __TBB_EXTRA_DEBUG 228 using traits_type::allow_multimapping;
230 using base_type::insert;
233 typedef Key key_type;
234 typedef typename base_type::value_type value_type;
235 typedef T mapped_type;
236 typedef Hasher hasher;
237 typedef Key_equality key_equal;
240 typedef typename base_type::allocator_type allocator_type;
241 typedef typename base_type::pointer pointer;
242 typedef typename base_type::const_pointer const_pointer;
243 typedef typename base_type::reference reference;
244 typedef typename base_type::const_reference const_reference;
246 typedef typename base_type::size_type size_type;
247 typedef typename base_type::difference_type difference_type;
249 typedef typename base_type::iterator iterator;
250 typedef typename base_type::const_iterator const_iterator;
251 typedef typename base_type::iterator local_iterator;
252 typedef typename base_type::const_iterator const_local_iterator;
256 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
257 const allocator_type& a = allocator_type())
258 : base_type(n_of_buckets, key_compare(_Hasher, _Key_equality), a)
266 template <
typename Iterator>
268 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
269 const allocator_type& a = allocator_type())
270 : base_type(n_of_buckets,key_compare(_Hasher,_Key_equality), a)
275 #if __TBB_INITIALIZER_LISTS_PRESENT 278 const hasher& _Hasher = hasher(),
const key_equal& _Key_equality = key_equal(),
279 const allocator_type& a = allocator_type())
280 : base_type(n_of_buckets, key_compare(_Hasher, _Key_equality), a)
282 this->insert(il.begin(),il.end());
284 #endif //# __TBB_INITIALIZER_LISTS_PRESENT 286 #if __TBB_CPP11_IMPLICIT_MOVE_MEMBERS_GENERATION_BROKEN 292 concurrent_unordered_multimap& operator=(
const concurrent_unordered_multimap& table)
294 return static_cast<concurrent_unordered_multimap&
>(base_type::operator=(table));
297 concurrent_unordered_multimap(concurrent_unordered_multimap&& table)
298 : base_type(std::move(table))
302 concurrent_unordered_multimap& operator=(concurrent_unordered_multimap&& table)
304 return static_cast<concurrent_unordered_multimap&
>(base_type::operator=(std::move(table)));
306 #endif //__TBB_CPP11_IMPLICIT_MOVE_MEMBERS_GENERATION_BROKEN 308 concurrent_unordered_multimap(
const concurrent_unordered_multimap& table,
const Allocator& a)
309 : base_type(table, a)
313 #if __TBB_CPP11_RVALUE_REF_PRESENT 314 concurrent_unordered_multimap(concurrent_unordered_multimap&& table,
const Allocator& a) : base_type(std::move(table), a)
326 #endif// __TBB_concurrent_unordered_map_H Definition: concurrent_unordered_map.h:217
Definition: concurrent_unordered_map.h:48
Definition: concurrent_unordered_map.h:74
Definition: concurrent_unordered_map.h:36
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Definition: _tbb_hash_compare_impl.h:33