4 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
\r
9 * concurrent_unordered_map.h
\r
11 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
\r
16 #include "internal_concurrent_hash.h"
\r
18 #if !(defined(_M_AMD64) || defined(_M_IX86))
\r
19 #error ERROR: Concurrency Runtime is supported only on X64 and X86 architectures.
\r
23 #error ERROR: Concurrency Runtime is not supported when compiling /clr.
\r
26 #pragma pack(push,_CRT_PACKING)
\r
28 namespace Concurrency
\r
32 // Template class for hash map traits
\r
33 template<typename _Key_type, typename _Element_type, typename _Key_comparator, typename _Allocator_type, bool _Allow_multimapping>
\r
34 class _Concurrent_unordered_map_traits : public std::_Container_base
\r
37 typedef std::pair<_Key_type, _Element_type> _Value_type;
\r
38 typedef std::pair<const _Key_type, _Element_type> value_type;
\r
39 typedef _Key_type key_type;
\r
40 typedef _Key_comparator key_compare;
\r
42 typedef typename _Allocator_type::template rebind<value_type>::other allocator_type;
\r
46 _M_allow_multimapping = _Allow_multimapping
\r
49 _Concurrent_unordered_map_traits() : _M_comparator()
\r
53 _Concurrent_unordered_map_traits(const key_compare& _Traits) : _M_comparator(_Traits)
\r
57 class value_compare : public std::binary_function<value_type, value_type, bool>
\r
59 friend class _Concurrent_unordered_map_traits<_Key_type, _Element_type, _Key_comparator, _Allocator_type, _Allow_multimapping>;
\r
62 bool operator()(const value_type& _Left, const value_type& _Right) const
\r
64 return (_M_comparator(_Left.first, _Right.first));
\r
67 value_compare(const key_compare& _Traits) : _M_comparator(_Traits)
\r
72 key_compare _M_comparator; // the comparator predicate for keys
\r
75 template<class _Type1, class _Type2>
\r
76 static const _Type1& _Key_function(const std::pair<_Type1, _Type2>& _Value)
\r
78 return (_Value.first);
\r
80 key_compare _M_comparator; // the comparator predicate for keys
\r
82 } // namespace details;
\r
85 /// The <c>concurrent_unordered_map</c> class is an concurrency-safe container that controls a varying-length sequence of
\r
86 /// elements of type std::pair<const _Key_type, _Element_type>. The sequence is represented in a way that enables
\r
87 /// concurrency-safe append, element access, iterator access and iterator traversal operations.
\r
89 /// <typeparam name="_Key_type">
\r
92 /// <typeparam name="_Element_type">
\r
93 /// The mapped type.
\r
95 /// <typeparam name="_Hasher">
\r
96 /// The hash function object type. This argument is optional and the default value is
\r
97 /// tr1::hash<</c><typeparamref name="_Key_type"/><c>></c>.
\r
99 /// <typeparam name="_Key_equality">
\r
100 /// The equality comparison function object type. This argument is optional and the default value is
\r
101 /// <c>equal_to<</c><typeparamref name="_Key_type"/><c>></c>.
\r
103 /// <typeparam name="_Allocator_type">
\r
104 /// The type that represents the stored allocator object that encapsulates details about the allocation and
\r
105 /// deallocation of memory for the concurrent vector. This argument is optional and the default value is
\r
106 /// <c>allocator<</c><typeparamref name="_Key_type"/>, <typeparamref name="_Element_type"/><c>></c>.
\r
109 /// For detailed information on the <c>concurrent_unordered_map</c> class, see <see cref="Parallel Containers and Objects"/>.
\r
111 /// <seealso cref="Parallel Containers and Objects"/>
\r
113 template <typename _Key_type, typename _Element_type, typename _Hasher = std::tr1::hash<_Key_type>, typename _Key_equality = std::equal_to<_Key_type>, typename _Allocator_type = std::allocator<std::pair<const _Key_type, _Element_type> > >
\r
114 class concurrent_unordered_map : public details::_Concurrent_hash< details::_Concurrent_unordered_map_traits<_Key_type, _Element_type, details::_Hash_compare<_Key_type, _Hasher, _Key_equality>, _Allocator_type, false> >
\r
117 // Base type definitions
\r
118 typedef concurrent_unordered_map<_Key_type, _Element_type, _Hasher, _Key_equality, _Allocator_type> _Mytype;
\r
119 typedef details::_Hash_compare<_Key_type, _Hasher, _Key_equality> _Mytraits;
\r
120 typedef details::_Concurrent_hash< details::_Concurrent_unordered_map_traits<_Key_type, _Element_type, _Mytraits, _Allocator_type, false> > _Mybase;
\r
122 // Type definitions
\r
123 typedef _Key_type key_type;
\r
124 typedef typename _Mybase::value_type value_type;
\r
125 typedef _Element_type mapped_type;
\r
126 typedef _Hasher hasher;
\r
127 typedef _Key_equality key_equal;
\r
128 typedef _Mytraits key_compare;
\r
130 typedef typename _Mybase::allocator_type allocator_type;
\r
131 typedef typename _Mybase::pointer pointer;
\r
132 typedef typename _Mybase::const_pointer const_pointer;
\r
133 typedef typename _Mybase::reference reference;
\r
134 typedef typename _Mybase::const_reference const_reference;
\r
136 typedef typename _Mybase::size_type size_type;
\r
137 typedef typename _Mybase::difference_type difference_type;
\r
139 typedef typename _Mybase::iterator iterator;
\r
140 typedef typename _Mybase::const_iterator const_iterator;
\r
141 typedef typename _Mybase::iterator local_iterator;
\r
142 typedef typename _Mybase::const_iterator const_local_iterator;
\r
145 /// Constructs a concurrent unordered map.
\r
147 /// <param name="_Number_of_buckets">
\r
148 /// The initial number of buckets for this unordered map.
\r
150 /// <param name="_Hasher">
\r
151 /// The hash function for this unordered map.
\r
153 /// <param name="_Key_equality">
\r
154 /// The equality comparison function for this unordered map.
\r
156 /// <param name="_Allocator">
\r
157 /// The allocator for this unordered map.
\r
160 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
161 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
162 /// hash function, equality function and allocator type to be used.</para>
\r
163 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
164 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
165 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
166 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
169 explicit concurrent_unordered_map(size_type _Number_of_buckets = 8, const hasher& _Hasher = hasher(), const key_equal& _Key_equality = key_equal(),
\r
170 const allocator_type& _Allocator = allocator_type())
\r
171 : _Mybase(_Number_of_buckets, key_compare(_Hasher, _Key_equality), _Allocator)
\r
173 this->rehash(_Number_of_buckets);
\r
177 /// Constructs a concurrent unordered map.
\r
179 /// <param name="_Allocator">
\r
180 /// The allocator for this unordered map.
\r
183 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
184 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
185 /// hash function, equality function and allocator type to be used.</para>
\r
186 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
187 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
188 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
189 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
192 concurrent_unordered_map(const allocator_type& _Allocator) : _Mybase(8, key_compare(), _Allocator)
\r
197 /// Constructs a concurrent unordered map.
\r
199 /// <typeparam name="_Iterator">
\r
200 /// The type of the input iterator.
\r
202 /// <param name="_Begin">
\r
203 /// Position of the first element in the range of elements to be copied.
\r
205 /// <param name="_End">
\r
206 /// Position of the first element beyond the range of elements to be copied.
\r
208 /// <param name="_Number_of_buckets">
\r
209 /// The initial number of buckets for this unordered map.
\r
211 /// <param name="_Hasher">
\r
212 /// The hash function for this unordered map.
\r
214 /// <param name="_Key_equality">
\r
215 /// The equality comparison function for this unordered map.
\r
217 /// <param name="_Allocator">
\r
218 /// The allocator for this unordered map.
\r
221 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
222 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
223 /// hash function, equality function and allocator type to be used.</para>
\r
224 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
225 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
226 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
227 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
230 template <typename _Iterator>
\r
231 concurrent_unordered_map(_Iterator _Begin, _Iterator _End, size_type _Number_of_buckets = 8, const hasher& _Hasher = hasher(),
\r
232 const key_equal& _Key_equality = key_equal(), const allocator_type& _Allocator = allocator_type())
\r
233 : _Mybase(_Number_of_buckets, key_compare(), allocator_type())
\r
235 this->rehash(_Number_of_buckets);
\r
236 for (; _Begin != _End; ++_Begin)
\r
238 _Mybase::insert(*_Begin);
\r
243 /// Constructs a concurrent unordered map.
\r
245 /// <param name="_Umap">
\r
246 /// The source <c>concurrent_unordered_map</c> object to copy or move elements from.
\r
249 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
250 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
251 /// hash function, equality function and allocator type to be used.</para>
\r
252 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
253 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
254 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
255 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
258 concurrent_unordered_map(const concurrent_unordered_map& _Umap) : _Mybase(_Umap)
\r
263 /// Constructs a concurrent unordered map.
\r
265 /// <param name="_Umap">
\r
266 /// The source <c>concurrent_unordered_map</c> object to copy or move elements from.
\r
268 /// <param name="_Allocator">
\r
269 /// The allocator for this unordered map.
\r
272 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
273 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
274 /// hash function, equality function and allocator type to be used.</para>
\r
275 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
276 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
277 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
278 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
281 concurrent_unordered_map(const concurrent_unordered_map& _Umap, const allocator_type& _Allocator) : _Mybase(_Umap, _Allocator)
\r
286 /// Constructs a concurrent unordered map.
\r
288 /// <param name="_Umap">
\r
289 /// The source <c>concurrent_unordered_map</c> object to copy or move elements from.
\r
292 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered map.
\r
293 /// <para>The first constructor specifies an empty initial map and explicitly specifies the number of buckets,
\r
294 /// hash function, equality function and allocator type to be used.</para>
\r
295 /// <para>The second constructor specifies an allocator for the unordered map.<para>
\r
296 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
297 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
298 /// <para>The last constructor specifies a move of the concurrent unordered map <paramref name="_Umap"/>.</para>
\r
301 concurrent_unordered_map(concurrent_unordered_map&& _Umap) : _Mybase(std::move(_Umap))
\r
306 /// Assigns the contents of another <c>concurrent_unordered_map</c> object to this one. This method is not concurrency-safe.
\r
308 /// <param name="_Umap">
\r
309 /// The source <c>concurrent_unordered_map</c> object.
\r
312 /// A reference to this <c>concurrent_unordered_map</c> object.
\r
315 /// After erasing any existing elements a concurrent vector, <c>operator=</c> either copies or moves the contents of <paramref name="_Umap"/> into
\r
316 /// the concurrent vector.
\r
319 concurrent_unordered_map& operator=(const concurrent_unordered_map& _Umap)
\r
321 _Mybase::operator=(_Umap);
\r
326 /// Assigns the contents of another <c>concurrent_unordered_map</c> object to this one. This method is not concurrency-safe.
\r
328 /// <param name="_Umap">
\r
329 /// The source <c>concurrent_unordered_map</c> object.
\r
332 /// A reference to this <c>concurrent_unordered_map</c> object.
\r
335 /// After erasing any existing elements in a concurrent vector, <c>operator=</c> either copies or moves the contents of <paramref name="_Umap"/> into
\r
336 /// the concurrent vector.
\r
339 concurrent_unordered_map& operator=(concurrent_unordered_map&& _Umap)
\r
341 _Mybase::operator=(std::move(_Umap));
\r
346 /// Erases elements from the <c>concurrent_unordered_map</c>. This method is not concurrency-safe.
\r
348 /// <param name="_Where">
\r
349 /// The iterator position to erase from.
\r
352 /// The first function erases an element from the map given an iterator position.
\r
353 /// <para>The second function erases an element matching a key</para>
\r
354 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
357 /// The iterator for this <c>concurrent_unordered_map</c> object.
\r
360 iterator unsafe_erase(const_iterator _Where)
\r
362 return _Mybase::unsafe_erase(_Where);
\r
366 /// Erases elements from the <c>concurrent_unordered_map</c>. This method is not concurrency-safe.
\r
368 /// <param name="_Keyval">
\r
369 /// The key to erase.
\r
372 /// The first function erases an element from the map given an iterator position.
\r
373 /// <para>The second function erases an element matching a key</para>
\r
374 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
377 /// The count of elements erased from this <c>concurrent_unordered_map</c> object.
\r
380 size_type unsafe_erase(const key_type& _Keyval)
\r
382 return _Mybase::unsafe_erase(_Keyval);
\r
386 /// Erases elements from the <c>concurrent_unordered_map</c>. This method is not concurrency-safe.
\r
388 /// <param name="_Begin">
\r
389 /// Position of the first element in the range of elements to be erased.
\r
391 /// <param name="_End">
\r
392 /// Position of the first element beyond the range of elements to be erased.
\r
395 /// The first function erases an element from the map given an iterator position.
\r
396 /// <para>The second function erases an element matching a key</para>
\r
397 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
400 /// The iterator for this <c>concurrent_unordered_map</c> object.
\r
403 iterator unsafe_erase(const_iterator _Begin, const_iterator _End)
\r
405 return _Mybase::unsafe_erase(_Begin, _End);
\r
409 /// Swaps the contents of two <c>concurrent_unordered_map</c> objects.
\r
410 /// This method is not concurrency-safe.
\r
412 /// <param name="_Umap">
\r
413 /// The <c>concurrent_unordered_map</c> object to swap with.
\r
416 void swap(concurrent_unordered_map& _Umap)
\r
418 _Mybase::swap(_Umap);
\r
423 /// The hash function object.
\r
426 hasher hash_function() const
\r
428 return _M_comparator._M_hash_object;
\r
432 /// The equality comparison function object.
\r
435 key_equal key_eq() const
\r
437 return _M_comparator._M_key_compare_object;
\r
441 /// Provides access to the element at the given key in the concurrent unordered map. This method is concurrency-safe.
\r
443 /// <param name="_Keyval">
\r
444 /// The key of the element to be retrieved.
\r
447 /// A element mapped to by the key.
\r
450 mapped_type& operator[](const key_type& _Keyval)
\r
452 iterator _Where = find(_Keyval);
\r
454 if (_Where == end())
\r
456 _Where = insert(std::pair<key_type, mapped_type>(std::move(_Keyval), mapped_type())).first;
\r
459 return ((*_Where).second);
\r
463 /// Provides access to the element at the given key in the concurrent unordered map. This method is concurrency-safe.
\r
465 /// <param name="_Keyval">
\r
466 /// The key of the element to be retrieved.
\r
469 /// A element mapped to by the key.
\r
472 mapped_type& at(const key_type& _Keyval)
\r
474 iterator _Where = find(_Keyval);
\r
476 if (_Where == end())
\r
478 throw std::out_of_range("invalid concurrent_unordered_map<K, T> key");
\r
481 return ((*_Where).second);
\r
485 /// Provides read access to the element at the given key in the concurrent unordered map. This method is concurrency-safe.
\r
487 /// <param name="_Keyval">
\r
488 /// The key of the element to be retrieved.
\r
491 /// A element mapped to by the key.
\r
494 const mapped_type& at(const key_type& _Keyval) const
\r
496 const_iterator _Where = find(_Keyval);
\r
498 if (_Where == end())
\r
500 throw std::out_of_range("invalid concurrent_unordered_map<K, T> key");
\r
503 return ((*_Where).second);
\r
508 /// The <c>concurrent_unordered_multimap</c> class is an concurrency-safe container that controls a varying-length sequence of
\r
509 /// elements of type std::pair<const _Key_type, _Element_type>. The sequence is represented in a way that enables
\r
510 /// concurrency-safe append, element access, iterator access and iterator traversal operations.
\r
512 /// <typeparam name="_Key_type">
\r
515 /// <typeparam name="_Element_type">
\r
516 /// The mapped type.
\r
518 /// <typeparam name="_Hasher">
\r
519 /// The hash function object type. This argument is optional and the default value is
\r
520 /// tr1::hash<</c><typeparamref name="_Key_type"/><c>></c>.
\r
522 /// <typeparam name="_Key_equality">
\r
523 /// The equality comparison function object type. This argument is optional and the default value is
\r
524 /// <c>equal_to<</c><typeparamref name="_Key_type"/><c>></c>.
\r
526 /// <typeparam name="_Allocator_type">
\r
527 /// The type that represents the stored allocator object that encapsulates details about the allocation and
\r
528 /// deallocation of memory for the concurrent vector. This argument is optional and the default value is
\r
529 /// <c>allocator<</c><typeparamref name="_Key_type"/>, <typeparamref name="_Element_type"/><c>></c>.
\r
532 /// For detailed information on the <c>concurrent_unordered_multimap</c> class, see <see cref="Parallel Containers and Objects"/>.
\r
534 /// <seealso cref="Parallel Containers and Objects"/>
\r
536 template <typename _Key_type, typename _Element_type, typename _Hasher = std::tr1::hash<_Key_type>, typename _Key_equality = std::equal_to<_Key_type>, typename _Allocator_type = std::allocator<std::pair<const _Key_type, _Element_type> > >
\r
537 class concurrent_unordered_multimap : public details::_Concurrent_hash< details::_Concurrent_unordered_map_traits<_Key_type, _Element_type, details::_Hash_compare<_Key_type, _Hasher, _Key_equality>, _Allocator_type, true> >
\r
540 // Base type definitions
\r
541 typedef concurrent_unordered_multimap<_Key_type, _Element_type, _Hasher, _Key_equality, _Allocator_type> _Mytype;
\r
542 typedef details::_Hash_compare<_Key_type, _Hasher, _Key_equality> _Mytraits;
\r
543 typedef details::_Concurrent_hash< details::_Concurrent_unordered_map_traits<_Key_type, _Element_type, _Mytraits, _Allocator_type, true> > _Mybase;
\r
545 // Type definitions
\r
546 typedef _Key_type key_type;
\r
547 typedef typename _Mybase::value_type value_type;
\r
548 typedef _Element_type mapped_type;
\r
549 typedef _Hasher hasher;
\r
550 typedef _Key_equality key_equal;
\r
551 typedef _Mytraits key_compare;
\r
553 typedef typename _Mybase::allocator_type allocator_type;
\r
554 typedef typename _Mybase::pointer pointer;
\r
555 typedef typename _Mybase::const_pointer const_pointer;
\r
556 typedef typename _Mybase::reference reference;
\r
557 typedef typename _Mybase::const_reference const_reference;
\r
559 typedef typename _Mybase::size_type size_type;
\r
560 typedef typename _Mybase::difference_type difference_type;
\r
562 typedef typename _Mybase::iterator iterator;
\r
563 typedef typename _Mybase::const_iterator const_iterator;
\r
564 typedef typename _Mybase::iterator local_iterator;
\r
565 typedef typename _Mybase::const_iterator const_local_iterator;
\r
568 /// Constructs a concurrent unordered multimap.
\r
570 /// <param name="_Number_of_buckets">
\r
571 /// The initial number of buckets for this unordered multimap.
\r
573 /// <param name="_Hasher">
\r
574 /// The hash function for this unordered multimap.
\r
576 /// <param name="_Key_equality">
\r
577 /// The equality comparison function for this unordered multimap.
\r
579 /// <param name="_Allocator">
\r
580 /// The allocator for this unordered multimap.
\r
583 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
584 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
585 /// hash function, equality function and allocator type to be used.</para>
\r
586 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
587 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
588 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
589 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
592 explicit concurrent_unordered_multimap(size_type _Number_of_buckets = 8, const hasher& _Hasher = hasher(), const key_equal& _Key_equality = key_equal(),
\r
593 const allocator_type& _Allocator = allocator_type())
\r
594 : _Mybase(_Number_of_buckets, key_compare(_Hasher, _Key_equality), _Allocator)
\r
596 this->rehash(_Number_of_buckets);
\r
600 /// Constructs a concurrent unordered multimap.
\r
602 /// <param name="_Allocator">
\r
603 /// The allocator for this unordered multimap.
\r
606 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
607 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
608 /// hash function, equality function and allocator type to be used.</para>
\r
609 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
610 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
611 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
612 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
615 concurrent_unordered_multimap(const allocator_type& _Allocator) : _Mybase(8, key_compare(), _Allocator)
\r
620 /// Constructs a concurrent unordered multimap.
\r
622 /// <typeparam name="_Iterator">
\r
623 /// The type of the input iterator.
\r
625 /// <param name="_Begin">
\r
626 /// Position of the first element in the range of elements to be copied.
\r
628 /// <param name="_End">
\r
629 /// Position of the first element beyond the range of elements to be copied.
\r
631 /// <param name="_Number_of_buckets">
\r
632 /// The initial number of buckets for this unordered multimap.
\r
634 /// <param name="_Hasher">
\r
635 /// The hash function for this unordered multimap.
\r
637 /// <param name="_Key_equality">
\r
638 /// The equality comparison function for this unordered multimap.
\r
640 /// <param name="_Allocator">
\r
641 /// The allocator for this unordered multimap.
\r
644 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
645 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
646 /// hash function, equality function and allocator type to be used.</para>
\r
647 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
648 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
649 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
650 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
653 template <typename _Iterator>
\r
654 concurrent_unordered_multimap(_Iterator _Begin, _Iterator _End, size_type _Number_of_buckets = 8, const hasher& _Hasher = hasher(),
\r
655 const key_equal& _Key_equality = key_equal(), const allocator_type& _Allocator = allocator_type())
\r
656 : _Mybase(_Number_of_buckets, key_compare(), allocator_type())
\r
658 this->rehash(_Number_of_buckets);
\r
659 for (; _Begin != _End; ++_Begin)
\r
661 _Mybase::insert(*_Begin);
\r
666 /// Constructs a concurrent unordered multimap.
\r
668 /// <param name="_Umap">
\r
669 /// The source <c>concurrent_unordered_multimap</c> object to copy elements from.
\r
672 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
673 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
674 /// hash function, equality function and allocator type to be used.</para>
\r
675 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
676 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
677 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
678 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
681 concurrent_unordered_multimap(const concurrent_unordered_multimap& _Umap) : _Mybase(_Umap)
\r
686 /// Constructs a concurrent unordered multimap.
\r
688 /// <param name="_Umap">
\r
689 /// The source <c>concurrent_unordered_multimap</c> object to copy elements from.
\r
691 /// <param name="_Allocator">
\r
692 /// The allocator for this unordered multimap.
\r
695 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
696 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
697 /// hash function, equality function and allocator type to be used.</para>
\r
698 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
699 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
700 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
701 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
704 concurrent_unordered_multimap(const concurrent_unordered_multimap& _Umap, const allocator_type& _Allocator) : _Mybase(_Umap, _Allocator)
\r
709 /// Constructs a concurrent unordered multimap.
\r
711 /// <param name="_Umap">
\r
712 /// The source <c>concurrent_unordered_multimap</c> object to copy elements from.
\r
715 /// All constructors store an allocator object <paramref name="_Allocator"/> and initialize the unordered multimap.
\r
716 /// <para>The first constructor specifies an empty initial multimap and explicitly specifies the number of buckets,
\r
717 /// hash function, equality function and allocator type to be used.</para>
\r
718 /// <para>The second constructor specifies an allocator for the unordered multimap.<para>
\r
719 /// <para>The third constructor specifies values supplied by the iterator range [<paramref name="_Begin"/>, <paramref name="_End"/>).</para>
\r
720 /// <para>The fourth and fifth constructors specify a copy of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
721 /// <para>The last constructor specifies a move of the concurrent unordered multimap <paramref name="_Umap"/>.</para>
\r
724 concurrent_unordered_multimap(concurrent_unordered_multimap&& _Umap) : _Mybase(std::move(_Umap))
\r
729 /// Assigns the contents of another <c>concurrent_unordered_multimap</c> object to this one. This method is not concurrency-safe.
\r
731 /// <param name="_Umap">
\r
732 /// The source <c>concurrent_unordered_multimap</c> object.
\r
735 /// A reference to this <c>concurrent_unordered_multimap</c> object.
\r
738 /// After erasing any existing elements in a concurrent unordered multimap, <c>operator=</c> either copies or moves the contents of
\r
739 /// <paramref name="_Umap"/> into the concurrent unordered multimap.
\r
742 concurrent_unordered_multimap& operator=(const concurrent_unordered_multimap& _Umap)
\r
744 _Mybase::operator=(_Umap);
\r
749 /// Assigns the contents of another <c>concurrent_unordered_multimap</c> object to this one. This method is not concurrency-safe.
\r
751 /// <param name="_Umap">
\r
752 /// The source <c>concurrent_unordered_multimap</c> object.
\r
755 /// A reference to this <c>concurrent_unordered_multimap</c> object.
\r
758 /// After erasing any existing elements in a concurrent unordered multimap, <c>operator=</c> either copies or moves the contents of
\r
759 /// <paramref name="_Umap"/> into the concurrent unordered multimap.
\r
762 concurrent_unordered_multimap& operator=(concurrent_unordered_multimap&& _Umap)
\r
764 _Mybase::operator=(std::move(_Umap));
\r
770 /// Inserts a value into the <c>concurrent_unordered_multimap</c> object.
\r
772 /// <param name="_Value">
\r
773 /// The value to be inserted into the <c>concurrent_unordered_multimap</c> object.
\r
776 /// The first function determines whether an element X exists in the sequence whose key has equivalent ordering to
\r
777 /// that of _Value. If not, it creates such an element X and initializes it with _Value. The function then determines the
\r
778 /// iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise,
\r
779 /// it returns std::pair(where, false).
\r
780 /// <para>The second function uses the <c>const_iterator _Where</c> as a starting location to search for an insertion point</para>
\r
781 /// <para>The third function inserts the sequence of element values, from the range [_First, _Last).</para>
\r
782 /// <para>The last two functions behave the same as the first two, except that <paramref name="_Value"/> is used to construct the inserted value.</para>
\r
785 /// An iterator pointing to the insertion location.
\r
788 iterator insert(const value_type& _Value)
\r
790 return (_Mybase::insert(_Value)).first;
\r
794 /// Inserts a value into the <c>concurrent_unordered_multimap</c> object.
\r
796 /// <param name="_Where">
\r
797 /// The starting location to search for an insertion point into the <c>concurrent_unordered_multimap</c> object.
\r
799 /// <param name="_Value">
\r
800 /// The value to be inserted into the <c>concurrent_unordered_multimap</c> object.
\r
803 /// The first function determines whether an element X exists in the sequence whose key has equivalent ordering to
\r
804 /// that of _Value. If not, it creates such an element X and initializes it with _Value. The function then determines the
\r
805 /// iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise,
\r
806 /// it returns std::pair(where, false).
\r
807 /// <para>The second function uses the <c>const_iterator _Where</c> as a starting location to search for an insertion point</para>
\r
808 /// <para>The third function inserts the sequence of element values, from the range [_First, _Last).</para>
\r
809 /// <para>The last two functions behave the same as the first two, except that <paramref name="_Value"/> is used to construct the inserted value.</para>
\r
812 /// The iterator for the <c>concurrent_unordered_multimap</c> object.
\r
814 iterator insert(const_iterator _Where, const value_type& _Value)
\r
816 return _Mybase::insert(_Where, _Value);
\r
820 /// Inserts values into the <c>concurrent_unordered_multimap</c> object.
\r
822 /// <typeparam name="_Iterator">
\r
823 /// The iterator type used for insertion.
\r
825 /// <param name="_First">
\r
826 /// The starting location in an itertor of elements to insert into the <c>concurrent_unordered_multimap</c> object.
\r
828 /// <param name="_Last">
\r
829 /// The ending location in an itertor of elements to insert into the <c>concurrent_unordered_multimap</c> object.
\r
832 /// The first function determines whether an element X exists in the sequence whose key has equivalent ordering to
\r
833 /// that of _Value. If not, it creates such an element X and initializes it with _Value. The function then determines the
\r
834 /// iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise,
\r
835 /// it returns std::pair(where, false).
\r
836 /// <para>The second function uses the <c>const_iterator _Where</c> as a starting location to search for an insertion point</para>
\r
837 /// <para>The third function inserts the sequence of element values, from the range [_First, _Last).</para>
\r
838 /// <para>The last two functions behave the same as the first two, except that <paramref name="_Value"/> is used to construct the inserted value.</para>
\r
840 template<class _Iterator>
\r
841 void insert(_Iterator _First, _Iterator _Last)
\r
843 _Mybase::insert(_First, _Last);
\r
847 /// Inserts a value into the <c>concurrent_unordered_multimap</c> object.
\r
849 /// <typeparam name="_Valty">
\r
850 /// The type of the value inserted into the map.
\r
852 /// <param name="_Value">
\r
853 /// The value to be inserted into the <c>concurrent_unordered_multimap</c> object.
\r
856 /// The first function determines whether an element X exists in the sequence whose key has equivalent ordering to
\r
857 /// that of _Value. If not, it creates such an element X and initializes it with _Value. The function then determines the
\r
858 /// iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise,
\r
859 /// it returns std::pair(where, false).
\r
860 /// <para>The second function uses the <c>const_iterator _Where</c> as a starting location to search for an insertion point</para>
\r
861 /// <para>The third function inserts the sequence of element values, from the range [_First, _Last).</para>
\r
862 /// <para>The last two functions behave the same as the first two, except that <paramref name="_Value"/> is used to construct the inserted value.</para>
\r
865 /// An iterator pointing to the insertion location.
\r
868 template<class _Valty>
\r
869 iterator insert(_Valty&& _Value)
\r
871 return (_Mybase::insert(std::forward<_Valty>(_Value))).first;
\r
875 /// Inserts a value into the <c>concurrent_unordered_multimap</c> object.
\r
877 /// <typeparam name="_Valty">
\r
878 /// The type of the value inserted into the map.
\r
880 /// <param name="_Where">
\r
881 /// The starting location to search for an insertion point into the <c>concurrent_unordered_multimap</c> object.
\r
883 /// <param name="_Value">
\r
884 /// The value to be inserted into the <c>concurrent_unordered_multimap</c> object.
\r
887 /// The first function determines whether an element X exists in the sequence whose key has equivalent ordering to
\r
888 /// that of _Value. If not, it creates such an element X and initializes it with _Value. The function then determines the
\r
889 /// iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise,
\r
890 /// it returns std::pair(where, false).
\r
891 /// <para>The second function uses the <c>const_iterator _Where</c> as a starting location to search for an insertion point</para>
\r
892 /// <para>The third function inserts the sequence of element values, from the range [_First, _Last).</para>
\r
893 /// <para>The last two functions behave the same as the first two, except that <paramref name="_Value"/> is used to construct the inserted value.</para>
\r
896 /// The iterator for the <c>concurrent_unordered_multimap</c> object.
\r
898 template<class _Valty>
\r
899 typename std::tr1::enable_if<!std::tr1::is_same<const_iterator,
\r
900 typename std::tr1::remove_reference<_Valty>::type>::value, iterator>::type
\r
901 insert(const_iterator _Where, _Valty&& _Value)
\r
903 return _Mybase::insert(_Where, std::forward<_Valty>(_Value));
\r
907 /// Erases elements from the <c>concurrent_unordered_multimap</c>. This method is not concurrency-safe.
\r
909 /// <param name="_Where">
\r
910 /// The iterator position to erase from.
\r
913 /// The first function erases an element from the map given an iterator position.
\r
914 /// <para>The second function erases an element matching a key</para>
\r
915 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
918 /// The iterator for this <c>concurrent_unordered_multimap</c> object.
\r
921 iterator unsafe_erase(const_iterator _Where)
\r
923 return _Mybase::unsafe_erase(_Where);
\r
927 /// Erases elements from the <c>concurrent_unordered_multimap</c>. This method is not concurrency-safe.
\r
929 /// <param name="_Keyval">
\r
930 /// The key to erase.
\r
933 /// The first function erases an element from the map given an iterator position.
\r
934 /// <para>The second function erases an element matching a key</para>
\r
935 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
938 /// The count of elements erased from this <c>concurrent_unordered_multimap</c> object.
\r
941 size_type unsafe_erase(const key_type& _Keyval)
\r
943 return _Mybase::unsafe_erase(_Keyval);
\r
947 /// Erases elements from the <c>concurrent_unordered_multimap</c>. This method is not concurrency-safe.
\r
949 /// <param name="_Begin">
\r
950 /// Position of the first element in the range of elements to be erased.
\r
952 /// <param name="_End">
\r
953 /// Position of the first element beyond the range of elements to be erased.
\r
956 /// The first function erases an element from the map given an iterator position.
\r
957 /// <para>The second function erases an element matching a key</para>
\r
958 /// <para>The third function erases elements given an iterator begin and end position</para>
\r
961 /// The iterator for this <c>concurrent_unordered_multimap</c> object.
\r
964 iterator unsafe_erase(const_iterator _First, const_iterator _Last)
\r
966 return _Mybase::unsafe_erase(_First, _Last);
\r
970 /// Swaps the contents of two <c>concurrent_unordered_multimap</c> objects.
\r
971 /// This method is not concurrency-safe.
\r
973 /// <param name="_Umap">
\r
974 /// The <c>concurrent_unordered_multimap</c> object to swap with.
\r
977 void swap(concurrent_unordered_multimap& _Umap)
\r
979 _Mybase::swap(_Umap);
\r
984 /// The hash function object.
\r
987 hasher hash_function() const
\r
989 return _M_comparator._M_hash_object;
\r
993 /// The equality comparison function object.
\r
996 key_equal key_eq() const
\r
998 return _M_comparator._M_key_compare_object;
\r
1001 } // namespace Concurrency
\r