BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_unorderedmultimap_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_unorderedmultimap_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_unorderedmultimap_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_UNORDEREDMULTIMAP_CPP03
12#define INCLUDED_BSLSTL_UNORDEREDMULTIMAP_CPP03
13
14/// @defgroup bslstl_unorderedmultimap_cpp03 bslstl_unorderedmultimap_cpp03
15/// @brief Provide C++03 implementation for bslstl_unorderedmultimap.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_unorderedmultimap_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_unorderedmultimap_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_unorderedmultimap_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_unorderedmultimap_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_unorderedmultimap_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_unorderedmultimap.h
30///
31/// # Classes {#bslstl_unorderedmultimap_cpp03-classes}
32/// See bslstl_unorderedmultimap.h for list of classes
33///
34/// @see bslstl_unorderedmultimap
35///
36/// # Description {#bslstl_unorderedmultimap_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Sun Sep 1 18:48:19 2024
48/// Command line: sim_cpp11_features.pl bslstl_unorderedmultimap.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_unorderedmultimap_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_UNORDEREDMULTIMAP_H
64
65namespace bsl {
66
67/// This class template implements a value-semantic container type holding a
68/// collection of (possibly equivalent) keys (of the template parameter type
69/// `KEY`), each mapped to their associated values (of another template
70/// parameter type `VALUE`).
71///
72/// This class:
73/// * supports a complete set of *value-semantic* operations
74/// - except for BDEX serialization
75/// * is *exception-neutral* (agnostic except for the `at` method)
76/// * is *alias-safe*
77/// * is `const` *thread-safe*
78/// For terminology see @ref bsldoc_glossary .
79///
80/// See @ref bslstl_unorderedmultimap_cpp03
81template <class KEY,
82 class VALUE,
83 class HASH = bsl::hash<KEY>,
84 class EQUAL = bsl::equal_to<KEY>,
86class unordered_multimap {
87
88 private:
89 // PRIVATE TYPES
90
91 /// This `typedef` is an alias for the allocator traits type associated
92 /// with this container.
93 typedef bsl::allocator_traits<ALLOCATOR> AllocatorTraits;
94
95 /// This `typedef` is an alias for the type of key-value pair objects
96 /// maintained by this unordered multimap.
97 typedef pair<const KEY, VALUE> ValueType;
98
99 /// This `typedef` is an alias for the policy used internally by this
100 /// container to extract the `KEY` value from the values maintained by
101 /// this unordered multimap.
102 typedef ::BloombergLP::bslstl::UnorderedMapKeyConfiguration<const KEY,
103 ValueType>
104 ListConfiguration;
105
106 /// This `typedef` is an alias for the template instantiation of the
107 /// underlying `bslstl::HashTable` used to implement this unordered
108 /// multimap.
109 typedef ::BloombergLP::bslstl::HashTable<ListConfiguration,
110 HASH,
111 EQUAL,
112 ALLOCATOR> Impl;
113
114 /// This `typedef` is an alias for the type of links maintained by the
115 /// linked list of elements held by the underlying `bslstl::HashTable`.
116 typedef ::BloombergLP::bslalg::BidirectionalLink HashTableLink;
117
118 /// This `typedef` is a convenient alias for the utility associated with
119 /// movable references.
120 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
121
122 // FRIENDS
123 template <class KEY2,
124 class VALUE2,
125 class HASH2,
126 class EQUAL2,
127 class ALLOCATOR2>
128 friend bool operator==(
129 const unordered_multimap<KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2>&,
130 const unordered_multimap<KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2>&);
131
132 public:
133 // PUBLIC TYPES
134 typedef KEY key_type;
135 typedef VALUE mapped_type;
137 typedef HASH hasher;
138 typedef EQUAL key_equal;
139 typedef ALLOCATOR allocator_type;
140
141 typedef value_type& reference;
142 typedef const value_type& const_reference;
143
144 typedef typename AllocatorTraits::size_type size_type;
146 typedef typename AllocatorTraits::pointer pointer;
148
149 typedef ::BloombergLP::bslstl::HashTableIterator<
151
152 typedef ::BloombergLP::bslstl::HashTableIterator<
154
155 typedef ::BloombergLP::bslstl::HashTableBucketIterator<
157
158 typedef ::BloombergLP::bslstl::HashTableBucketIterator<
160
161 private:
162 // DATA
163 Impl d_impl;
164
165 public:
166 // CREATORS
167
169 explicit unordered_multimap(size_type initialNumBuckets,
170 const HASH& hashFunction = HASH(),
171 const EQUAL& keyEqual = EQUAL(),
172 const ALLOCATOR& basicAllocator = ALLOCATOR());
173 unordered_multimap(size_type initialNumBuckets,
174 const HASH& hashFunction,
175 const ALLOCATOR& basicAllocator);
176 unordered_multimap(size_type initialNumBuckets,
177 const ALLOCATOR& basicAllocator);
178 /// Create an empty unordered multimap. Optionally specify an
179 /// `initialNumBuckets` indicating the minimum initial size of the array
180 /// of buckets of this container. If `initialNumBuckets` is not
181 /// supplied, a single empty bucket is used. Optionally specify a
182 /// `hashFunction` used to generate the hash values for the keys
183 /// contained in this unordered multimap. If `hashFunction` is not
184 /// supplied, a default-constructed object of the (template parameter)
185 /// type `HASH` is used. Optionally specify a key-equivalence functor
186 /// `keyEqual` used to verify that two keys are equivalent. If
187 /// `keyEqual` is not supplied, a default-constructed object of the
188 /// (template parameter) type `EQUAL` is used. Optionally specify a
189 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
190 /// supplied, a default-constructed object of the (template parameter)
191 /// type `ALLOCATOR` is used. If the type `ALLOCATOR` is
192 /// `bsl::allocator` (the default), then `basicAllocator`, if supplied,
193 /// shall be convertible to `bslma::Allocator *`. If the type
194 /// `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not
195 /// supplied, the currently installed default allocator is used.
196 explicit unordered_multimap(const ALLOCATOR& basicAllocator);
197
198 /// Create an unordered multimap having the same value as the specified
199 /// `original` object. Use a copy of `original.hash_function()` to
200 /// generate hash values for the keys contained in this unordered
201 /// multimap. Use a copy of `original.key_eq()` to verify that two keys
202 /// are equivalent. Use the allocator returned by
203 /// `bsl::allocator_traits<ALLOCATOR>::
204 /// select_on_container_copy_construction(original.get_allocator())` to
205 /// allocate memory. This method requires that the (template parameter)
206 /// types `KEY` and `VALUE` both be `copy-insertable` into this
207 /// unordered multimap (see {Requirements on `KEY` and `VALUE`}).
208 unordered_multimap(const unordered_multimap& original);
209
210 /// Create an unordered multimap having the same value as the specified
211 /// `original` object by moving (in constant time) the contents of
212 /// `original` to the new unordered multimap. Use a copy of
213 /// `original.hash_function()` to generate hash values for the keys
214 /// contained in this unordered multimap. Use a copy of
215 /// `original.key_eq()` to verify that two keys are equivalent. The
216 /// allocator associated with `original` is propagated for use in the
217 /// newly-created unordered multimap. `original` is left in a valid but
218 /// unspecified state.
220 BloombergLP::bslmf::MovableRef<unordered_multimap> original);
221
222 /// Create an unordered multimap having the same value as the specified
223 /// `original` object that uses the specified `basicAllocator` to supply
224 /// memory. Use a copy of `original.hash_function()` to generate hash
225 /// values for the keys contained in this unordered multimap. Use a
226 /// copy of `original.key_eq()` to verify that two keys are equivalent.
227 /// This method requires that the (template parameter) types `KEY` and
228 /// `VALUE` both be `copy-insertable` into this unordered multimap (see
229 /// {Requirements on `KEY` and `VALUE`}). Note that a
230 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
231 /// (template parameter) type `ALLOCATOR` is `bsl::allocator` (the
232 /// default).
234 const unordered_multimap& original,
235 const typename type_identity<ALLOCATOR>::type& basicAllocator);
236
237 /// Create an unordered multimap having the same value as the specified
238 /// `original` object that uses the specified `basicAllocator` to supply
239 /// memory. The contents of `original` are moved (in constant time) to
240 /// the new unordered multimap if `basicAllocator ==
241 /// original.get_allocator()`, and are move-inserted (in linear time)
242 /// using `basicAllocator` otherwise. `original` is left in a valid but
243 /// unspecified state. Use a copy of `original.hash_function()` to
244 /// generate hash values for the keys contained in this unordered
245 /// multimap. Use a copy of `original.key_eq()` to verify that two keys
246 /// are equivalent. This method requires that the (template parameter)
247 /// types `KEY` and `VALUE` both be `move-insertable` into this
248 /// unordered multimap (see {Requirements on `KEY` and `VALUE`}). Note
249 /// that a `bslma::Allocator *` can be supplied for `basicAllocator` if
250 /// the (template parameter) type `ALLOCATOR` is `bsl::allocator` (the
251 /// default).
253 BloombergLP::bslmf::MovableRef<unordered_multimap> original,
254 const typename type_identity<ALLOCATOR>::type& basicAllocator);
255
256 /// Create an unordered multimap, and insert each `value_type` object in
257 /// the sequence starting at the specified `first` element, and ending
258 /// immediately before the specified `last` element. Optionally specify
259 /// an `initialNumBuckets` indicating the minimum initial size of the
260 /// array of buckets of this container. If `initialNumBuckets` is not
261 /// supplied, a single empty bucket is used if `first` and `last` denote
262 /// an empty range, and an unspecified number of buckets is used
263 /// otherwise. Optionally specify a `hashFunction` used to generate
264 /// hash values for the keys contained in this unordered multimap. If
265 /// `hashFunction` is not supplied, a default-constructed object of
266 /// (template parameter) type `HASH` is used. Optionally specify a
267 /// key-equivalence functor `keyEqual` used to verify that two keys are
268 /// equivalent. If `keyEqual` is not supplied, a default-constructed
269 /// object of (template parameter) type `EQUAL` is used. Optionally
270 /// specify a `basicAllocator` used to supply memory. If
271 /// `basicAllocator` is not supplied, a default-constructed object of
272 /// the (template parameter) type `ALLOCATOR` is used. If the type
273 /// `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not
274 /// supplied, the currently installed default allocator is used to
275 /// supply memory. The (template parameter) type `INPUT_ITERATOR` shall
276 /// meet the requirements of an input iterator defined in the C++11
277 /// standard [24.2.3] providing access to values of a type convertible
278 /// to `value_type`, and `value_type` must be `emplace-constructible`
279 /// from `*i` into this unordered multimap, where `i` is a
280 /// dereferenceable iterator in the range `[first .. last)` (see
281 /// {Requirements on `KEY` and `VALUE`}). The behavior is undefined
282 /// unless `first` and `last` refer to a sequence of valid values where
283 /// `first` is at a position at or before `last`. Note that a
284 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
285 /// type `ALLOCATOR` is `bsl::allocator` (the default).
286 template <class INPUT_ITERATOR>
287 unordered_multimap(INPUT_ITERATOR first,
288 INPUT_ITERATOR last,
289 size_type initialNumBuckets = 0,
290 const HASH& hashFunction = HASH(),
291 const EQUAL& keyEqual = EQUAL(),
292 const ALLOCATOR& basicAllocator = ALLOCATOR());
293 template <class INPUT_ITERATOR>
294 unordered_multimap(INPUT_ITERATOR first,
295 INPUT_ITERATOR last,
296 size_type initialNumBuckets,
297 const HASH& hashFunction,
298 const ALLOCATOR& basicAllocator);
299 template <class INPUT_ITERATOR>
300 unordered_multimap(INPUT_ITERATOR first,
301 INPUT_ITERATOR last,
302 size_type initialNumBuckets,
303 const ALLOCATOR& basicAllocator);
304 template <class INPUT_ITERATOR>
305 unordered_multimap(INPUT_ITERATOR first,
306 INPUT_ITERATOR last,
307 const ALLOCATOR& basicAllocator);
308
309#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
310# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
311 template <
312 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
313 class = bsl::enable_if_t<
314 std::is_invocable_v<EQUAL, const KEY &, const KEY &>>,
315 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
316 >
317# endif
319 std::initializer_list<value_type> values,
320 size_type initialNumBuckets = 0,
321 const HASH& hashFunction = HASH(),
322 const EQUAL& keyEqual = EQUAL(),
323 const ALLOCATOR& basicAllocator = ALLOCATOR());
324# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
325 template <
326 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
327 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
328 >
329# endif
330 unordered_multimap(std::initializer_list<value_type> values,
331 size_type initialNumBuckets,
332 const HASH& hashFunction,
333 const ALLOCATOR& basicAllocator);
334# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
335 template <
336 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
337 >
338# endif
339 unordered_multimap(std::initializer_list<value_type> values,
340 size_type initialNumBuckets,
341 const ALLOCATOR& basicAllocator);
342# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
343 /// Create an unordered multimap and insert each `value_type` object in
344 /// the specified `values` initializer list. Optionally specify an
345 /// `initialNumBuckets` indicating the minimum initial size of the array
346 /// of buckets of this container. If `initialNumBuckets` is not
347 /// supplied, a single empty bucket is used if `values` is empty, and an
348 /// unspecified number of buckets is used otherwise. Optionally specify
349 /// a `hashFunction` used to generate the hash values for the keys
350 /// contained in this unordered multimap. If `hashFunction` is not
351 /// supplied, a default-constructed object of the (template parameter)
352 /// type `HASH` is used. Optionally specify a key-equivalence functor
353 /// `keyEqual` used to verify that two keys are equivalent. If
354 /// `keyEqual` is not supplied, a default-constructed object of the
355 /// (template parameter) type `EQUAL` is used. Optionally specify a
356 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
357 /// supplied, a default-constructed object of the (template parameter)
358 /// type `ALLOCATOR` is used. If the type `ALLOCATOR` is
359 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
360 /// installed default allocator is used to supply memory. This method
361 /// requires that the (template parameter) types `KEY` and `VALUE` both
362 /// be `copy-insertable` into this unordered multimap (see {Requirements
363 /// on `KEY` and `VALUE`}). Note that a `bslma::Allocator *` can be
364 /// supplied for `basicAllocator` if the type `ALLOCATOR` is
365 /// `bsl::allocator` (the default).
366 template <
367 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
368 >
369# endif
370 unordered_multimap(std::initializer_list<value_type> values,
371 const ALLOCATOR& basicAllocator);
372#endif
373
374 /// Destroy this object.
376
377 // MANIPULATORS
378
379 /// Assign to this object the value, hash function, and key-equivalence
380 /// comparator of the specified `rhs` object, propagate to this object
381 /// the allocator of `rhs` if the `ALLOCATOR` type has trait
382 /// `propagate_on_container_copy_assignment`, and return a reference
383 /// providing modifiable access to this object. If an exception is
384 /// thrown, `*this` is left in a valid but unspecified state. This
385 /// method requires that the (template parameter) types `KEY` and
386 /// `VALUE` both be `copy-assignable` and `copy-insertable` into this
387 /// unordered multimap (see {Requirements on `KEY` and `VALUE`}).
388 unordered_multimap& operator=(const unordered_multimap& rhs);
389
390 /// Assign to this object the value, hash function, and key-equivalence
391 /// comparator of the specified `rhs` object, propagate to this object
392 /// the allocator of `rhs` if the `ALLOCATOR` type has trait
393 /// `propagate_on_container_move_assignment`, and return a reference
394 /// providing modifiable access to this object. The contents of `rhs`
395 /// are moved (in constant time) to this unordered multimap if
396 /// `get_allocator() == rhs.get_allocator()` (after accounting for the
397 /// aforementioned trait); otherwise, all elements in this unordered
398 /// multimap are either destroyed or move-assigned to, and each
399 /// additional element in `rhs` is move-inserted into this unordered
400 /// multimap. `rhs` is left in a valid but unspecified state, and if an
401 /// exception is thrown, `*this` is left in a valid but unspecified
402 /// state. This method requires that the (template parameter) types
403 /// `KEY` and `VALUE` both be `move-assignable` and `move-insertable`
404 /// into this unordered multimap (see {Requirements on `KEY` and
405 /// `VALUE`}).
407 operator=(BloombergLP::bslmf::MovableRef<unordered_multimap> rhs)
409 AllocatorTraits::is_always_equal::value &&
410 std::is_nothrow_move_assignable<HASH>::value &&
411 std::is_nothrow_move_assignable<EQUAL>::value);
412
413#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
414 /// Assign to this object the value resulting from first clearing this
415 /// unordered multimap and then inserting each `value_type` object in
416 /// the specified `values` initializer list, and return a reference
417 /// providing modifiable access to this object. This method requires
418 /// that the (template parameter) types `KEY` and `VALUE` both be
419 /// `copy-insertable` into this unordered multimap (see {Requirements on
420 /// `KEY` and `VALUE`}).
421 unordered_multimap& operator=(std::initializer_list<value_type> values);
422#endif
423
424 /// Return an iterator providing modifiable access to the first
425 /// `value_type` object (in the sequence of `value_type` objects)
426 /// maintained by this unordered multimap, or the `end` iterator if this
427 /// unordered multimap is empty.
429
430 /// Return an iterator providing modifiable access to the past-the-end
431 /// position in the sequence of `value_type` objects maintained by this
432 /// unordered multimap.
434
435 /// Return a local iterator providing modifiable access to the first
436 /// `value_type` object in the sequence of `value_type` objects of the
437 /// bucket having the specified `index` in the array of buckets
438 /// maintained by this unordered multimap, or the `end(index)` iterator
439 /// if the indexed bucket is empty. The behavior is undefined unless
440 /// `index < bucket_count()`.
441 local_iterator begin(size_type index);
442
443 /// Return a local iterator providing modifiable access to the
444 /// past-the-end position in the sequence of `value_type` objects of the
445 /// bucket having the specified `index` in the array of buckets
446 /// maintained by this unordered multimap. The behavior is undefined
447 /// unless `index < bucket_count()`.
448 local_iterator end(size_type index);
449
450 /// Remove all entries from this unordered multimap. Note that this
451 /// object will be empty after this call, but allocated memory may be
452 /// retained for future use.
454
455 /// Return a pair of iterators providing modifiable access to the
456 /// sequence of `value_type` objects in this unordered multimap with a
457 /// key equivalent to the specified `key`, where the first iterator is
458 /// positioned at the start of the sequence, and the second is
459 /// positioned one past the end of the sequence. If this unordered
460 /// multimap contains no `value_type` objects with a key equivalent to
461 /// `key`, then the two returned iterators will have the same value.
462 /// The behavior is undefined unless `key` is equivalent to the key of
463 /// the elements of at most one equivalent-key group in this unordered
464 /// multimap.
465 template <class LOOKUP_KEY>
466 typename enable_if<
467 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
468 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
469 pair<iterator, iterator> >::type
470 equal_range(const LOOKUP_KEY& key)
471 {
472 // Note: implemented inline due to Sun CC compilation error.
473 typedef bsl::pair<iterator, iterator> ResultType;
474 HashTableLink *first;
475 HashTableLink *last;
476 d_impl.findRange(&first, &last, key);
477 return ResultType(iterator(first), iterator(last));
478 }
479
480 /// Return a pair of iterators providing modifiable access to the
481 /// sequence of `value_type` objects in this unordered multimap with a
482 /// key equivalent to the specified `key`, where the first iterator is
483 /// positioned at the start of the sequence, and the second is
484 /// positioned one past the end of the sequence. If this unordered
485 /// multimap contains no `value_type` objects with a key equivalent to
486 /// `key`, then the two returned iterators will have the same value.
487 pair<iterator, iterator> equal_range(const key_type& key);
488
489 /// Remove from this unordered multimap all `value_type` objects with a
490 /// key equivalent to the specified `key`, if such exist, and return the
491 /// number of objects erased; otherwise, if there are no `value_type`
492 /// objects with a key equivalent to `key`, return 0 with no other
493 /// effect. This method invalidates only iterators and references to
494 /// the removed element and previously saved values of the `end()`
495 /// iterator, and preserves the relative order of the elements not
496 /// removed.
497 size_type erase(const key_type& key);
498
499 iterator erase(const_iterator position);
500 /// Remove from this unordered multimap the `value_type` object at the
501 /// specified `position`, and return an iterator referring to the
502 /// element immediately following the removed element, or to the
503 /// past-the-end position if the removed element was the last element in
504 /// the sequence of elements maintained by this unordered multimap.
505 /// This method invalidates only iterators and references to the removed
506 /// element and previously saved values of the `end()` iterator, and
507 /// preserves the relative order of the elements not removed. The
508 /// behavior is undefined unless `position` refers to a `value_type`
509 /// object in this unordered multimap.
510 iterator erase(iterator position);
511
512 /// Remove from this unordered multimap the `value_type` objects
513 /// starting at the specified `first` position up to, but not including,
514 /// the specified `last` position, and return `last`. This method
515 /// invalidates only iterators and references to the removed element and
516 /// previously saved values of the `end()` iterator, and preserves the
517 /// relative order of the elements not removed. The behavior is
518 /// undefined unless `first` and `last` either refer to elements in this
519 /// unordered multimap or are the `end` iterator, and the `first`
520 /// position is at or before the `last` position in the sequence
521 /// provided by this container.
523
524 /// Return an iterator providing modifiable access to the first
525 /// `value_type` object in the sequence of all the `value_type` objects
526 /// of this unordered multimap with a key equivalent to the specified
527 /// `key`, if such entries exist, and the past-the-end (`end`) iterator
528 /// otherwise. The behavior is undefined unless `key` is equivalent to
529 /// the key of the elements of at most one equivalent-key group in this
530 /// unordered multimap.
531 template <class LOOKUP_KEY>
532 typename enable_if<
533 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
534 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
535 iterator>::type
536 find(const LOOKUP_KEY& key)
537 {
538 // Note: implemented inline due to Sun CC compilation error.
539 return iterator(d_impl.find(key));
540 }
541
542 /// Return an iterator providing modifiable access to the first
543 /// `value_type` object in the sequence of all the `value_type` objects
544 /// of this unordered multimap with a key equivalent to the specified
545 /// `key`, if such entries exist, and the past-the-end (`end`) iterator
546 /// otherwise.
547 iterator find(const key_type& key);
548
549 /// Insert the specified `value` into this unordered multimap, and
550 /// return an iterator referring to the newly inserted `value_type`
551 /// object. This method requires that the (template parameter) types
552 /// `KEY` and `VALUE` both be `copy-insertable` into this unordered
553 /// multimap (see {Requirements on `KEY` and `VALUE`}).
554 iterator insert(const value_type& value);
555
556#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
557 template <class ALT_VALUE_TYPE>
559#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
560 template <class ALT_VALUE_TYPE>
561 typename enable_if<is_convertible<ALT_VALUE_TYPE, value_type>::value,
562 iterator>::type
563#else
564 /// Insert into this unordered multimap a `value_type` object created
565 /// from the specified `value`, and return an iterator referring to the
566 /// newly inserted `value_type` object. This method requires that the
567 /// (template parameter) types `KEY` and `VALUE` both be
568 /// `move-insertable` into this unordered multimap (see {Requirements on
569 /// `KEY` and `VALUE`}), and the `value_type` be constructible from the
570 /// (template parameter) `ALT_VALUE_TYPE`.
571 template <class ALT_VALUE_TYPE>
572 typename enable_if<std::is_constructible<value_type,
573 ALT_VALUE_TYPE&&>::value,
574 iterator>::type
575#endif
576 insert(BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value)
577 {
578 // Note that some compilers fail when this method is defined
579 // out-of-line.
580
581 return emplace(BSLS_COMPILERFEATURES_FORWARD(ALT_VALUE_TYPE, value));
582 }
583
584 /// Insert the specified `value` into this unordered multimap (in
585 /// constant time if the specified `hint` refers to an element in this
586 /// container with a key equivalent to the key of `value`), and return
587 /// an iterator referring to the newly inserted `value_type` object. If
588 /// `hint` does not refer to an element in this container with a key
589 /// equivalent to the key of `value`, this operation has worst case
590 /// `O[N]` and average case constant-time complexity, where `N` is the
591 /// size of this unordered multimap. This method requires that the
592 /// (template parameter) types `KEY` and `VALUE` both be
593 /// `copy-insertable` into this unordered multimap (see {Requirements on
594 /// `KEY` and `VALUE`}). The behavior is undefined unless `hint` is an
595 /// iterator in the range `[begin() .. end()]` (both endpoints
596 /// included).
597 iterator insert(const_iterator hint, const value_type& value);
598
599#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
600 template <class ALT_VALUE_TYPE>
602#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
603 template <class ALT_VALUE_TYPE>
604 typename enable_if<is_convertible<ALT_VALUE_TYPE, value_type>::value,
605 iterator>::type
606#else
607 /// Insert into this unordered multimap a `value_type` object created
608 /// from the specified `value` (in constant time if the specified `hint`
609 /// refers to an element in this container with a key equivalent to the
610 /// key of `value`), and return an iterator referring to the newly
611 /// inserted `value_type` object. If `hint` does not refer to an
612 /// element in this container with a key equivalent to the key of
613 /// `value`, this operation has worst case `O[N]` and average case
614 /// constant-time complexity, where `N` is the size of this unordered
615 /// multimap. This method requires that the (template parameter) types
616 /// `KEY` and `VALUE` both be `move-insertable` into this unordered
617 /// multimap (see {Requirements on `KEY` and `VALUE`}), and the
618 /// `value_type` be constructible from the (template parameter)
619 /// `ALT_VALUE_TYPE`. The behavior is undefined unless `hint` is an
620 /// iterator in the range `[begin() .. end()]` (both endpoints
621 /// included).
622 template <class ALT_VALUE_TYPE>
623 typename enable_if<std::is_constructible<value_type,
624 ALT_VALUE_TYPE&&>::value,
625 iterator>::type
626#endif
628 BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value)
629 {
630 // Note that some compilers fail when this method is defined
631 // out-of-line.
632
633 return emplace_hint(hint,
634 BSLS_COMPILERFEATURES_FORWARD(ALT_VALUE_TYPE, value));
635 }
636
637 /// Insert into this unordered multimap the value of each `value_type`
638 /// object in the range starting at the specified `first` iterator and
639 /// ending immediately before the specified `last` iterator. The
640 /// (template parameter) type `INPUT_ITERATOR` shall meet the
641 /// requirements of an input iterator defined in the C++11 standard
642 /// [24.2.3] providing access to values of a type convertible to
643 /// `value_type`, and `value_type` must be `emplace-constructible` from
644 /// `*i` into this unordered multimap, where `i` is a dereferenceable
645 /// iterator in the range `[first .. last)` (see {Requirements on `KEY`
646 /// and `VALUE`}). The behavior is undefined unless `first` and `last`
647 /// refer to a sequence of valid values where `first` is at a position
648 /// at or before `last`.
649 template <class INPUT_ITERATOR>
650 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
651
652#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
653 /// Insert into this unordered multimap the value of each `value_type`
654 /// object in the specified `values` initializer list. This method
655 /// requires that the (template parameter) types `KEY` and `VALUE` both
656 /// be `copy-insertable` into this unordered multimap (see {Requirements
657 /// on `KEY` and `VALUE`}).
658 void insert(std::initializer_list<value_type> values);
659#endif
660
661#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
662// {{{ BEGIN GENERATED CODE
663// Command line: sim_cpp11_features.pl bslstl_unorderedmultimap.h
664#ifndef BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT
665#define BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT 2
666#endif
667#ifndef BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A
668#define BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT
669#endif
670
671#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 0
673#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 0
674
675#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 1
676 template <class Args_1>
678#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 1
679
680#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 2
681 template <class Args_1,
682 class Args_2>
684 BSLS_COMPILERFEATURES_FORWARD_REF(Args_2) args_2);
685#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 2
686
687
688#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 0
690#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 0
691
692#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 1
693 template <class Args_1>
695 BSLS_COMPILERFEATURES_FORWARD_REF(Args_1) args_1);
696#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 1
697
698#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 2
699 template <class Args_1,
700 class Args_2>
703 BSLS_COMPILERFEATURES_FORWARD_REF(Args_2) args_2);
704#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_A >= 2
705
706#else
707// The generated code below is a workaround for the absence of perfect
708// forwarding in some compilers.
709
710 template <class... Args>
712
713 template <class... Args>
716
717// }}} END GENERATED CODE
718#endif
719
720 /// Set the maximum load factor of this container to the specified
721 /// `newLoadFactor`.
722 void max_load_factor(float newLoadFactor);
723
724 /// Change the size of the array of buckets maintained by this container
725 /// to the specified `numBuckets`, and redistribute all the contained
726 /// elements into the new sequence of buckets, according to their hash
727 /// values. Note that this operation has no effect if rehashing the
728 /// elements into `numBuckets` would cause this unordered multimap to
729 /// exceed its `max_load_factor`.
730 void rehash(size_type numBuckets);
731
732 /// Increase the number of buckets of this unordered multimap to a
733 /// quantity such that the ratio between the specified `numElements` and
734 /// the new number of buckets does not exceed `max_load_factor`. Note
735 /// that this guarantees that, after the reserve, elements can be
736 /// inserted to grow the container to `size() == numElements` without
737 /// rehashing. Also note that memory allocations may still occur when
738 /// growing the container to `size() == numElements`. Also note that
739 /// this operation has no effect if `numElements <= size()`.
740 void reserve(size_type numElements);
741
742 // Exchange the value, hasher, key-equality functor, and
743 // `max_load_factor` of this object with those of the specified `other`
744 // object; also exchange the allocator of this object with that of
745 // `other` if the (template parameter) type `ALLOCATOR` has the
746 // `propagate_on_container_swap` trait, and do not modify either
747 // allocator otherwise. This method provides the no-throw
748 // exception-safety guarantee if and only if both the (template
749 // parameter) types `HASH` and `EQUAL` provide no-throw swap
750 // operations; if an exception is thrown, both objects are left in
751 // valid but unspecified states. This operation guarantees `O[1]`
752 // complexity. The behavior is undefined unless either this object was
753 // created with the same allocator as `other` or `ALLOCATOR` has the
754 // `propagate_on_container_swap` trait.
756 AllocatorTraits::is_always_equal::value &&
757 bsl::is_nothrow_swappable<HASH>::value &&
758 bsl::is_nothrow_swappable<EQUAL>::value);
759
760 // ACCESSORS
761
762 /// Return (a copy of) the allocator used for memory allocation by this
763 /// unordered multimap.
765
767
768 /// Return an iterator providing non-modifiable access to the first
769 /// `value_type` object in the sequence of `value_type` objects
770 /// maintained by this unordered multimap, or the `end` iterator if this
771 /// unordered multimap is empty.
773
775
776 /// Return an iterator providing non-modifiable access to the
777 /// past-the-end position in the sequence of `value_type` objects
778 /// maintained by this unordered multimap.
780
781 /// Return `true` if this unordered map contains an element whose key is
782 /// equivalent to the specified `key`.
783 bool contains(const key_type &key) const;
784
785 /// Return `true` if this unordered map contains an element whose key is
786 /// equivalent to the specified `key`.
787 template <class LOOKUP_KEY>
788 typename enable_if<
789 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value &&
790 BloombergLP::bslmf::IsTransparentPredicate<EQUAL,
791 LOOKUP_KEY>::value,
792 bool>::type
793 contains(const LOOKUP_KEY& key) const
794 {
795 // Note: implemented inline due to Sun CC compilation error
796 return find(key) != end();
797 }
798
799 /// Return `true` if this unordered multimap contains no elements, and
800 /// `false` otherwise.
801 bool empty() const BSLS_KEYWORD_NOEXCEPT;
802
803 /// Return the number of elements in this unordered multimap.
805
806 /// Return a theoretical upper bound on the largest number of elements
807 /// that this unordered multimap could possibly hold. Note that there
808 /// is no guarantee that the unordered multimap can successfully grow to
809 /// the returned size, or even close to that size without running out of
810 /// resources.
812
813 /// Return (a copy of) the key-equivalence binary functor that returns
814 /// `true` if the value of two `key_type` objects are equivalent, and
815 /// `false` otherwise.
816 EQUAL key_eq() const;
817
818 /// Return (a copy of) the hash unary functor used by this unordered
819 /// multimap to generate a hash value (of type `size_type`) for a
820 /// `key_type` object.
821 HASH hash_function() const;
822
823 /// Return an iterator providing modifiable access to the first
824 /// `value_type` object in this unordered multimap whose key is
825 /// equivalent to the specified `key`, if such an entry exists, and the
826 /// past-the-end (`end`) iterator otherwise. The behavior is undefined
827 /// unless `key` is equivalent to the key of the elements of at most one
828 /// equivalent-key group in this unordered multimap.
829 template <class LOOKUP_KEY>
830 typename enable_if<
831 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
832 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
833 const_iterator>::type
834 find(const LOOKUP_KEY& key) const
835 {
836 // Note: implemented inline due to Sun CC compilation error.
837 return const_iterator(d_impl.find(key));
838 }
839
840 /// Return an iterator providing non-modifiable access to the first
841 /// `value_type` object in the sequence of `value_type` objects of this
842 /// unordered multimap with a key equivalent to the specified `key`, if
843 /// such entries exist, and the past-the-end (`end`) iterator otherwise.
844 const_iterator find(const key_type& key) const;
845
846 /// Return the number of `value_type` objects in this unordered multimap
847 /// with a key equivalent to the specified `key`. The behavior is
848 /// undefined unless `key` is equivalent to the key of the elements of
849 /// at most one equivalent-key group in this unordered multimap.
850 template <class LOOKUP_KEY>
851 typename enable_if<
852 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
853 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
854 size_type>::type
855 count(const LOOKUP_KEY& key) const
856 {
857 // Note: implemented inline due to Sun CC compilation error.
858 typedef ::BloombergLP::bslalg::BidirectionalNode<value_type> BNode;
859
860 size_type result = 0;
861 for (HashTableLink *cursor = d_impl.find(key);
862 cursor;
863 ++result, cursor = cursor->nextLink())
864 {
865 BNode *cursorNode = static_cast<BNode *>(cursor);
866 if (!this->key_eq()(
867 key,
868 ListConfiguration::extractKey(cursorNode->value()))) {
869
870 break;
871 }
872 }
873 return result;
874 }
875
876 /// Return the number of `value_type` objects in this unordered multimap
877 /// with a key equivalent to the specified `key`.
878 size_type count(const key_type& key) const;
879
880 /// Return a pair of iterators providing non-modifiable access to the
881 /// sequence of `value_type` objects in this unordered multimap with a
882 /// key equivalent to the specified `key`, where the first iterator is
883 /// positioned at the start of the sequence, and the second is
884 /// positioned one past the end of the sequence. If this unordered
885 /// multimap contains no `value_type` objects with a key equivalent to
886 /// `key`, then the two returned iterators will have the same value.
887 /// The behavior is undefined unless `key` is equivalent to the key of
888 /// the elements of at most one equivalent-key group in this unordered
889 /// multimap.
890 template <class LOOKUP_KEY>
891 typename enable_if<
892 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
893 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
894 pair<const_iterator, const_iterator> >::type
895 equal_range(const LOOKUP_KEY& key) const
896 {
897 // Note: implemented inline due to Sun CC compilation error.
899 HashTableLink *first;
900 HashTableLink *last;
901 d_impl.findRange(&first, &last, key);
902 return ResultType(const_iterator(first), const_iterator(last));
903 }
904
905 /// Return a pair of iterators providing non-modifiable access to the
906 /// sequence of `value_type` objects in this unordered multimap with a
907 /// key equivalent to the specified `key`, where the first iterator is
908 /// positioned at the start of the sequence, and the second is
909 /// positioned one past the end of the sequence. If this unordered
910 /// multimap contains no `value_type` objects with a key equivalent to
911 /// `key`, then the two returned iterators will have the same value.
912 pair<const_iterator, const_iterator> equal_range(
913 const key_type& key) const;
914
916
917 /// Return a local iterator providing non-modifiable access to the first
918 /// `value_type` object (in the sequence of `value_type` objects) of the
919 /// bucket having the specified `index` in the array of buckets
920 /// maintained by this unordered multimap, or the `end(index)` iterator
921 /// if the indexed bucket is empty. The behavior is undefined unless
922 /// `index < bucket_count()`.
924
926
927 /// Return a local iterator providing non-modifiable access to the
928 /// past-the-end position (in the sequence of `value_type` objects) of
929 /// the bucket having the specified `index` in the array of buckets
930 /// maintained by this unordered multimap. The behavior is undefined
931 /// unless `index < bucket_count()`.
933
934 /// Return the index of the bucket, in the array of buckets of this
935 /// container, where a value with a key equivalent to the specified
936 /// `key` would be inserted.
937 size_type bucket(const key_type& key) const;
938
939 /// Return the number of buckets in the array of buckets maintained by
940 /// this unordered multimap.
942
943 /// Return a theoretical upper bound on the largest number of buckets
944 /// that this container could possibly manage. Note that there is no
945 /// guarantee that the unordered multimap can successfully grow to the
946 /// returned size, or even close to that size without running out of
947 /// resources.
949
950 /// Return the number of elements contained in the bucket at the
951 /// specified `index` in the array of buckets maintained by this
952 /// container. The behavior is undefined unless
953 /// `index < bucket_count()`.
954 size_type bucket_size(size_type index) const;
955
956 /// Return the current ratio between the `size` of this container and
957 /// the number of buckets. The load factor is a measure of how full the
958 /// container is, and a higher load factor typically leads to an
959 /// increased number of collisions, thus resulting in a loss of
960 /// performance.
962
963 /// Return the maximum load factor allowed for this container. Note
964 /// that if an insert operation would cause the load factor to exceed
965 /// the `max_load_factor`, that same insert operation will increase the
966 /// number of buckets and rehash the elements of the container into
967 /// those buckets (see `rehash`).
969};
970
971#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
972// CLASS TEMPLATE DEDUCTION GUIDES
973
974/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
975/// of the iterators supplied to the constructor of @ref unordered_multimap .
976/// Deduce the template parameters `HASH`, `EQUAL` and `ALLOCATOR` from the
977/// other parameters passed to the constructor of @ref unordered_multimap .
978/// This deduction guide does not participate unless the supplied allocator
979/// meets the requirements of a standard allocator.
980template <
981 class INPUT_ITERATOR,
982 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
983 class VALUE =
984 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
985 class HASH = bsl::hash<KEY>,
986 class EQUAL = bsl::equal_to<KEY>,
987 class ALLOCATOR = bsl::allocator<pair<const KEY, VALUE>>,
988 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
989 class = bsl::enable_if_t<
990 std::is_invocable_v<EQUAL, const KEY &, const KEY &>>,
991 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
992 >
993unordered_multimap(INPUT_ITERATOR,
994 INPUT_ITERATOR,
995 typename bsl::allocator_traits<ALLOCATOR>::size_type = 0,
996 HASH = HASH(),
997 EQUAL = EQUAL(),
998 ALLOCATOR = ALLOCATOR())
999-> unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>;
1000
1001/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1002/// of the iterators supplied to the constructor of @ref unordered_multimap .
1003/// Deduce the template parameters `HASH` and "EQUAL' from the other
1004/// parameters passed to the constructor of @ref unordered_multimap . This
1005/// deduction guide does not participate unless the supplied allocator is
1006/// convertible to `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1007template <
1008 class INPUT_ITERATOR,
1009 class HASH,
1010 class EQUAL,
1011 class ALLOC,
1012 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1013 class VALUE =
1014 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1015 class DEFAULT_ALLOCATOR = bsl::allocator<pair<const KEY, VALUE>>,
1016 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1017 >
1019 INPUT_ITERATOR,
1020 INPUT_ITERATOR,
1021 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1022 HASH,
1023 EQUAL,
1024 ALLOC *)
1025-> unordered_multimap<KEY, VALUE, HASH, EQUAL>;
1026
1027/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1028/// of the iterators supplied to the constructor of @ref unordered_multimap .
1029/// Deduce the template parameters `HASH` and `ALLOCATOR` from the other
1030/// parameters passed to the constructor of @ref unordered_multimap . This
1031/// deduction guide does not participate unless the supplied hash is
1032/// invokable with a `KEY`, and the supplied allocator meets the
1033/// requirements of a standard allocator.
1034template <
1035 class INPUT_ITERATOR,
1036 class HASH,
1037 class ALLOCATOR,
1038 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1039 class VALUE =
1040 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1041 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
1042 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1043 >
1044unordered_multimap(INPUT_ITERATOR,
1045 INPUT_ITERATOR,
1046 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1047 HASH,
1048 ALLOCATOR)
1049-> unordered_multimap<KEY, VALUE, HASH, bsl::equal_to<KEY>, ALLOCATOR>;
1050
1051/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1052/// of the iterators supplied to the constructor of @ref unordered_multimap .
1053/// Deduce the template parameter `HASH` from the other parameters passed to
1054/// the constructor of @ref unordered_multimap . This deduction guide does not
1055/// participate unless the supplied allocator is convertible to
1056/// `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1057template <
1058 class INPUT_ITERATOR,
1059 class HASH,
1060 class ALLOC,
1061 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1062 class VALUE =
1063 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1064 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1065 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1066 >
1068 INPUT_ITERATOR,
1069 INPUT_ITERATOR,
1070 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1071 HASH,
1072 ALLOC *)
1073-> unordered_multimap<KEY, VALUE, HASH>;
1074
1075/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1076/// of the iterators supplied to the constructor of @ref unordered_multimap .
1077/// This deduction guide does not participate unless the supplied allocator
1078/// meets the requirements of a standard allocator.
1079template <
1080 class INPUT_ITERATOR,
1081 class ALLOCATOR,
1082 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1083 class VALUE =
1084 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1085 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1086 >
1087unordered_multimap(INPUT_ITERATOR,
1088 INPUT_ITERATOR,
1089 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1090 ALLOCATOR)
1091-> unordered_multimap<KEY,
1092 VALUE,
1093 bsl::hash<KEY>,
1094 bsl::equal_to<KEY>,
1095 ALLOCATOR>;
1096
1097/// of the iterators supplied to the constructor of @ref unordered_multimap .
1098/// Deduce the template parameter `ALLOCATOR` from the other parameter
1099/// passed to the constructor of @ref unordered_multimap . This deduction guide
1100/// does not participate unless the supplied allocator meets the
1101/// requirements of a standard allocator.
1102template <
1103 class INPUT_ITERATOR,
1104 class ALLOC,
1105 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1106 class VALUE =
1107 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1108 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1109 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1110 >
1112 INPUT_ITERATOR,
1113 INPUT_ITERATOR,
1114 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1115 ALLOC *)
1116-> unordered_multimap<KEY, VALUE>;
1117
1118/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1119/// of the iterators supplied to the constructor of @ref unordered_multimap .
1120/// Deduce the template parameter `ALLOCATOR` from the other parameter
1121/// passed to the constructor of @ref unordered_multimap . This deduction guide
1122/// does not participate unless the supplied allocator meets the
1123/// requirements of a standard allocator.
1124template <
1125 class INPUT_ITERATOR,
1126 class ALLOCATOR,
1127 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1128 class VALUE =
1129 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1130 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1131 >
1132unordered_multimap(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR)
1133-> unordered_multimap<KEY,
1134 VALUE,
1135 bsl::hash<KEY>,
1136 bsl::equal_to<KEY>,
1137 ALLOCATOR>;
1138
1139/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1140/// of the iterators supplied to the constructor of @ref unordered_multimap .
1141/// This deduction guide does not participate unless the supplied allocator
1142/// is convertible to `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1143template <
1144 class INPUT_ITERATOR,
1145 class ALLOC,
1146 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1147 class VALUE =
1148 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1149 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1150 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1151 >
1152unordered_multimap(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1153-> unordered_multimap<KEY, VALUE>;
1154
1155/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1156/// of the initializer_list supplied to the constructor of
1157/// @ref unordered_multimap . Deduce the template parameters `HASH`, `EQUAL`
1158/// and `ALLOCATOR` from the other parameters supplied to the constructor of
1159/// @ref unordered_multimap . This deduction guide does not participate unless:
1160/// (1) the supplied `HASH` is invokable with a `KEY`, (2) the supplied
1161/// `EQUAL` is invokable with two `KEY`s, and (3) the supplied allocator
1162/// meets the requirements of a standard allocator.
1163template <
1164 class KEY,
1165 class VALUE,
1166 class HASH = bsl::hash<KEY>,
1167 class EQUAL = bsl::equal_to<KEY>,
1168 class ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1169 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
1170 class = bsl::enable_if_t<
1171 std::is_invocable_v<EQUAL, const KEY &, const KEY &>>,
1172 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1173 >
1174unordered_multimap(std::initializer_list<bsl::pair<const KEY, VALUE>>,
1175 typename bsl::allocator_traits<ALLOCATOR>::size_type = 0,
1176 HASH = HASH(),
1177 EQUAL = EQUAL(),
1178 ALLOCATOR = ALLOCATOR())
1179-> unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>;
1180
1181/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1182/// of the initializer_list supplied to the constructor of
1183/// @ref unordered_multimap . Deduce the template parameters `HASH`, `EQUAL`
1184/// and `ALLOCATOR` from the other parameters supplied to the constructor of
1185/// @ref unordered_multimap . This deduction guide does not participate unless
1186/// the supplied allocator is convertible to
1187/// `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1188template <
1189 class KEY,
1190 class VALUE,
1191 class HASH,
1192 class EQUAL,
1193 class ALLOC,
1194 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1195 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1196 >
1198 std::initializer_list<bsl::pair<const KEY, VALUE>>,
1199 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1200 HASH,
1201 EQUAL,
1202 ALLOC *)
1203-> unordered_multimap<KEY, VALUE, HASH, EQUAL>;
1204
1205/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1206/// of the initializer_list supplied to the constructor of
1207/// @ref unordered_multimap . Deduce the template parameters `HASH` and
1208/// `ALLOCATOR` from the other parameters supplied to the constructor of
1209/// @ref unordered_multimap . This deduction guide does not participate unless
1210/// the supplied `HASH` is invokable with a `KEY`, and the supplied
1211/// allocator meets the requirements of a standard allocator.
1212template <
1213 class KEY,
1214 class VALUE,
1215 class HASH,
1216 class ALLOCATOR,
1217 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
1218 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1219 >
1220unordered_multimap(std::initializer_list<bsl::pair<const KEY, VALUE>>,
1221 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1222 HASH,
1223 ALLOCATOR)
1224-> unordered_multimap<KEY, VALUE, HASH, bsl::equal_to<KEY>, ALLOCATOR>;
1225
1226/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1227/// of the initializer_list supplied to the constructor of
1228/// @ref unordered_multimap . Deduce the template parameter `HASH` from the
1229/// other parameters supplied to the constructor of @ref unordered_multimap .
1230/// This deduction guide does not participate unless the supplied allocator
1231/// is convertible to `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1232template <
1233 class KEY,
1234 class VALUE,
1235 class HASH,
1236 class ALLOC,
1237 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1238 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1239 >
1241 std::initializer_list<bsl::pair<const KEY, VALUE>>,
1242 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1243 HASH,
1244 ALLOC *)
1245-> unordered_multimap<KEY, VALUE, HASH>;
1246
1247/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1248/// of the initializer_list supplied to the constructor of
1249/// @ref unordered_multimap . This deduction guide does not participate unless
1250/// the supplied allocator meets the requirements of a standard allocator.
1251template <
1252 class KEY,
1253 class VALUE,
1254 class ALLOCATOR,
1255 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1256 >
1257unordered_multimap(std::initializer_list<bsl::pair<const KEY, VALUE>>,
1258 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1259 ALLOCATOR)
1260-> unordered_multimap<KEY,
1261 VALUE,
1262 bsl::hash<KEY>,
1263 bsl::equal_to<KEY>,
1264 ALLOCATOR>;
1265
1266/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1267/// of the initializer_list supplied to the constructor of
1268/// @ref unordered_multimap . This deduction guide does not participate unless
1269/// the supplied allocator is convertible to
1270/// `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1271template <
1272 class KEY,
1273 class VALUE,
1274 class ALLOC,
1275 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1276 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1277 >
1279 std::initializer_list<bsl::pair<const KEY, VALUE>>,
1280 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1281 ALLOC *)
1282-> unordered_multimap<KEY, VALUE>;
1283
1284/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1285/// of the initializer_list supplied to the constructor of
1286/// @ref unordered_multimap . Deduce the template parameter `ALLOCATOR` from
1287/// the other parameters supplied to the constructor of
1288/// @ref unordered_multimap . This deduction guide does not participate unless
1289/// the supplied allocator meets the requirements of a standard allocator.
1290template <
1291 class KEY,
1292 class VALUE,
1293 class ALLOCATOR,
1294 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1295 >
1296unordered_multimap(std::initializer_list<bsl::pair<const KEY, VALUE>>,
1297 ALLOCATOR)
1298-> unordered_multimap<KEY,
1299 VALUE,
1300 bsl::hash<KEY>,
1301 bsl::equal_to<KEY>,
1302 ALLOCATOR>;
1303
1304/// Deduce the template parameters `KEY` and `VALUE` from the `value_type`
1305/// of the initializer_list supplied to the constructor of
1306/// @ref unordered_multimap . This deduction guide does not participate unless
1307/// the supplied allocator is convertible to
1308/// `bsl::allocator<bsl::pair<const KEY, VALUE>>`.
1309template <
1310 class KEY,
1311 class VALUE,
1312 class ALLOC,
1313 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1314 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1315 >
1316unordered_multimap(std::initializer_list<bsl::pair<const KEY, VALUE>>, ALLOC *)
1317-> unordered_multimap<KEY, VALUE>;
1318#endif
1319
1320// FREE OPERATORS
1321
1322/// Return `true` if the specified `lhs` and `rhs` objects have the same
1323/// value, and `false` otherwise. Two @ref unordered_multimap objects have the
1324/// same value if they have the same number of key-value pairs, and each
1325/// key-value pair that is contained in one of the objects is also contained
1326/// in the other object. This method requires that the (template parameter)
1327/// types `KEY` and `VALUE` both be `equality-comparable` (see {Requirements
1328/// on `KEY` and `VALUE`}).
1329template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1330bool operator==(
1331 const unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& lhs,
1332 const unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& rhs);
1333
1334#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1335template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1336bool operator!=(
1337 const unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& lhs,
1338 const unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& rhs);
1339 // Return 'true' if the specified 'lhs' and 'rhs' objects do not have the
1340 // same value, and 'false' otherwise. Two @ref unordered_multimap objects do
1341 // not have the same value if they do not have the same number of key-value
1342 // pairs, or some key-value pair that is contained in one of the objects is
1343 // not also contained in the other object. This method requires that the
1344 // (template parameter) types 'KEY' and 'VALUE' both be
1345 // 'equality-comparable' (see {Requirements on 'KEY' and 'VALUE'}).
1346#endif
1347
1348// FREE FUNCTIONS
1349
1350/// Exchange the value, hasher, key-equality functor, and `max_load_factor`
1351/// of the specified `a` object with those of the specified `b` object; also
1352/// exchange the allocator of `a` with that of `b` if the (template
1353/// parameter) type `ALLOCATOR` has the `propagate_on_container_swap` trait,
1354/// and do not modify either allocator otherwise. This function provides
1355/// the no-throw exception-safety guarantee if and only if both the
1356/// (template parameter) types `HASH` and `EQUAL` provide no-throw swap
1357/// operations; if an exception is thrown, both objects are left in valid
1358/// but unspecified states. This operation guarantees `O[1]` complexity.
1359/// The behavior is undefined unless either `a` was created with the same
1360/// allocator as `b` or `ALLOCATOR` has the `propagate_on_container_swap`
1361/// trait.
1362template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1363void swap(unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& a,
1364 unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>& b)
1366
1367// ============================================================================
1368// TEMPLATE AND INLINE FUNCTION DEFINITIONS
1369// ============================================================================
1370
1371 //-------------------------
1372 // class unordered_multimap
1373 //-------------------------
1374
1375// CREATORS
1376template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1377inline
1378unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap()
1379: d_impl(HASH(), EQUAL(), 0, 1.0f, ALLOCATOR())
1380{
1381}
1382
1383template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1384inline
1386 size_type initialNumBuckets,
1387 const HASH& hashFunction,
1388 const EQUAL& keyEqual,
1389 const ALLOCATOR& basicAllocator)
1390: d_impl(hashFunction, keyEqual, initialNumBuckets, 1.0f, basicAllocator)
1391{
1392}
1393
1394template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1395inline
1396unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1397 size_type initialNumBuckets,
1398 const HASH& hashFunction,
1399 const ALLOCATOR& basicAllocator)
1400: d_impl(hashFunction, EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1401{
1402}
1403
1404template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1405inline
1406unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1407 size_type initialNumBuckets,
1408 const ALLOCATOR& basicAllocator)
1409: d_impl(HASH(), EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1410{
1411}
1412
1413template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1414inline
1415unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1416 const ALLOCATOR& basicAllocator)
1417: d_impl(basicAllocator)
1418{
1419}
1420
1421template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1422inline
1423unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1424 const unordered_multimap& original)
1425: d_impl(original.d_impl,
1426 AllocatorTraits::select_on_container_copy_construction(
1427 original.get_allocator()))
1428{
1429}
1430
1431template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1432inline
1433unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1434 BloombergLP::bslmf::MovableRef<unordered_multimap> original)
1435: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl))
1436{
1437}
1438
1439template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1440inline
1441unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1442 const unordered_multimap& original,
1443 const typename type_identity<ALLOCATOR>::type& basicAllocator)
1444: d_impl(original.d_impl, basicAllocator)
1445{
1446}
1447
1448template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1449inline
1450unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1451 BloombergLP::bslmf::MovableRef<unordered_multimap> original,
1452 const typename type_identity<ALLOCATOR>::type& basicAllocator)
1453: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl), basicAllocator)
1454{
1455}
1456
1457template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1458template <class INPUT_ITERATOR>
1459inline
1460unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1461 INPUT_ITERATOR first,
1462 INPUT_ITERATOR last,
1463 size_type initialNumBuckets,
1464 const HASH& hashFunction,
1465 const EQUAL& keyEqual,
1466 const ALLOCATOR& basicAllocator)
1467: d_impl(hashFunction, keyEqual, initialNumBuckets, 1.0f, basicAllocator)
1468{
1469 this->insert(first, last);
1470}
1471
1472template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1473template <class INPUT_ITERATOR>
1474inline
1475unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1476 INPUT_ITERATOR first,
1477 INPUT_ITERATOR last,
1478 size_type initialNumBuckets,
1479 const HASH& hashFunction,
1480 const ALLOCATOR& basicAllocator)
1481: d_impl(hashFunction, EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1482{
1483 this->insert(first, last);
1484}
1485
1486template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1487template <class INPUT_ITERATOR>
1488inline
1489unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1490 INPUT_ITERATOR first,
1491 INPUT_ITERATOR last,
1492 size_type initialNumBuckets,
1493 const ALLOCATOR& basicAllocator)
1494: d_impl(HASH(), EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1495{
1496 this->insert(first, last);
1497}
1498
1499template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1500template <class INPUT_ITERATOR>
1501inline
1502unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1503 INPUT_ITERATOR first,
1504 INPUT_ITERATOR last,
1505 const ALLOCATOR& basicAllocator)
1506: d_impl(HASH(), EQUAL(), 0, 1.0f, basicAllocator)
1507{
1508 this->insert(first, last);
1509}
1510
1511#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1512template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1513# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1514template <class, class, class>
1515# endif
1516inline
1517unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1518 std::initializer_list<value_type> values,
1519 size_type initialNumBuckets,
1520 const HASH& hashFunction,
1521 const EQUAL& keyEqual,
1522 const ALLOCATOR& basicAllocator)
1523: unordered_multimap(values.begin(),
1524 values.end(),
1525 initialNumBuckets,
1526 hashFunction,
1527 keyEqual,
1528 basicAllocator)
1529{
1530}
1531
1532template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1533# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1534template <class, class>
1535# endif
1536inline
1537unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1538 std::initializer_list<value_type> values,
1539 size_type initialNumBuckets,
1540 const HASH& hashFunction,
1541 const ALLOCATOR& basicAllocator)
1542: unordered_multimap(values.begin(),
1543 values.end(),
1544 initialNumBuckets,
1545 hashFunction,
1546 EQUAL(),
1547 basicAllocator)
1548{
1549}
1550
1551template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1552# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1553template <class>
1554# endif
1555inline
1556unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1557 std::initializer_list<value_type> values,
1558 size_type initialNumBuckets,
1559 const ALLOCATOR& basicAllocator)
1560: unordered_multimap(values.begin(),
1561 values.end(),
1562 initialNumBuckets,
1563 HASH(),
1564 EQUAL(),
1565 basicAllocator)
1566{
1567}
1568
1569template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1570# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1571template <class>
1572# endif
1573inline
1574unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::unordered_multimap(
1575 std::initializer_list<value_type> values,
1576 const ALLOCATOR& basicAllocator)
1577: unordered_multimap(values.begin(),
1578 values.end(),
1579 0,
1580 HASH(),
1581 EQUAL(),
1582 basicAllocator)
1583{
1584}
1585#endif // defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1586
1587template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1588unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::~unordered_multimap()
1589{
1590 // All memory management is handled by the base 'd_impl' member.
1591}
1592
1593// MANIPULATORS
1594template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1595unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>&
1596unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::operator=(
1597 const unordered_multimap& rhs)
1598{
1599 // Note that we have delegated responsibility for correct handling of
1600 // allocator propagation to the 'HashTable' implementation.
1601
1602 d_impl = rhs.d_impl;
1603
1604 return *this;
1605}
1606
1607template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1608inline
1609unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>&
1610unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::operator=(
1611 BloombergLP::bslmf::MovableRef<unordered_multimap> rhs)
1613 AllocatorTraits::is_always_equal::value &&
1614 std::is_nothrow_move_assignable<HASH>::value &&
1615 std::is_nothrow_move_assignable<EQUAL>::value)
1616{
1617 // Note that we have delegated responsibility for correct handling of
1618 // allocator propagation to the 'HashTable' implementation.
1619
1620 unordered_multimap& lvalue = rhs;
1621
1622 d_impl = MoveUtil::move(lvalue.d_impl);
1623
1624 return *this;
1625}
1626
1627#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1628template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1629inline
1630unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>&
1631unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::operator=(
1632 std::initializer_list<value_type> values)
1633{
1634 unordered_multimap tmp(values.begin(), values.end(), d_impl.allocator());
1635
1636 d_impl.swap(tmp.d_impl);
1637
1638 return *this;
1639}
1640#endif
1641
1642#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1643// {{{ BEGIN GENERATED CODE
1644// Command line: sim_cpp11_features.pl bslstl_unorderedmultimap.h
1645#ifndef BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT
1646#define BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT 2
1647#endif
1648#ifndef BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B
1649#define BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT
1650#endif
1651#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 0
1652template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1653inline
1654typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1655unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace(
1656 )
1657{
1658 return iterator(d_impl.emplace(
1659 ));
1660
1661}
1662#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 0
1663
1664#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 1
1665template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1666template <class Args_1>
1667inline
1668typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1669unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace(
1670 BSLS_COMPILERFEATURES_FORWARD_REF(Args_1) args_1)
1671{
1672 return iterator(d_impl.emplace(
1673 BSLS_COMPILERFEATURES_FORWARD(Args_1, args_1)));
1674
1675}
1676#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 1
1677
1678#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 2
1679template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1680template <class Args_1,
1681 class Args_2>
1682inline
1683typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1684unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace(
1685 BSLS_COMPILERFEATURES_FORWARD_REF(Args_1) args_1,
1686 BSLS_COMPILERFEATURES_FORWARD_REF(Args_2) args_2)
1687{
1688 return iterator(d_impl.emplace(
1689 BSLS_COMPILERFEATURES_FORWARD(Args_1, args_1),
1690 BSLS_COMPILERFEATURES_FORWARD(Args_2, args_2)));
1691
1692}
1693#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 2
1694
1695
1696#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 0
1697template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1698inline
1699typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1700unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace_hint(
1701 const_iterator hint)
1702{
1703 return iterator(d_impl.emplaceWithHint(hint.node()));
1704}
1705#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 0
1706
1707#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 1
1708template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1709template <class Args_1>
1710inline
1711typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1712unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace_hint(
1713 const_iterator hint,
1714 BSLS_COMPILERFEATURES_FORWARD_REF(Args_1) args_1)
1715{
1716 return iterator(d_impl.emplaceWithHint(hint.node(),
1717 BSLS_COMPILERFEATURES_FORWARD(Args_1, args_1)));
1718}
1719#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 1
1720
1721#if BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 2
1722template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1723template <class Args_1,
1724 class Args_2>
1725inline
1726typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1727unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace_hint(
1728 const_iterator hint,
1729 BSLS_COMPILERFEATURES_FORWARD_REF(Args_1) args_1,
1730 BSLS_COMPILERFEATURES_FORWARD_REF(Args_2) args_2)
1731{
1732 return iterator(d_impl.emplaceWithHint(hint.node(),
1733 BSLS_COMPILERFEATURES_FORWARD(Args_1, args_1),
1734 BSLS_COMPILERFEATURES_FORWARD(Args_2, args_2)));
1735}
1736#endif // BSLSTL_UNORDEREDMULTIMAP_VARIADIC_LIMIT_B >= 2
1737
1738#else
1739// The generated code below is a workaround for the absence of perfect
1740// forwarding in some compilers.
1741template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1742template <class... Args>
1743inline
1744typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1745unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace(
1747{
1748 return iterator(d_impl.emplace(
1749 BSLS_COMPILERFEATURES_FORWARD(Args, args)...));
1750
1751}
1752
1753template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1754template <class... Args>
1755inline
1756typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1757unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::emplace_hint(
1758 const_iterator hint,
1760{
1761 return iterator(d_impl.emplaceWithHint(hint.node(),
1762 BSLS_COMPILERFEATURES_FORWARD(Args, args)...));
1763}
1764// }}} END GENERATED CODE
1765#endif
1766
1767template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1768inline
1769typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1770unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::begin()
1772{
1773 return iterator(d_impl.elementListRoot());
1774}
1775
1776template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1777inline
1778typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1779unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::end()
1781{
1782 return iterator();
1783}
1784
1785template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1786inline
1787typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::local_iterator
1788unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::begin(size_type index)
1789{
1790 BSLS_ASSERT_SAFE(index < this->bucket_count());
1791
1792 return local_iterator(&d_impl.bucketAtIndex(index));
1793}
1794
1795template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1796inline
1797typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::local_iterator
1798unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::end(size_type index)
1799{
1800 BSLS_ASSERT_SAFE(index < this->bucket_count());
1801
1802 return local_iterator(0, &d_impl.bucketAtIndex(index));
1803}
1804
1805
1806template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1807inline
1808void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::clear()
1810{
1811 d_impl.removeAll();
1812}
1813
1814template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1815inline
1816bool unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::contains(
1817 const key_type& key) const
1818{
1819 return find(key) != end();
1820}
1821
1822template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1823inline
1824typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1825unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::find(
1826 const key_type& key)
1827{
1828 return iterator(d_impl.find(key));
1829}
1830
1831template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1832bsl::pair<
1833 typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator,
1834 typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator>
1835unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::equal_range(
1836 const key_type& key)
1837{
1838 HashTableLink *first;
1839 HashTableLink *last;
1840 d_impl.findRange(&first, &last, key);
1841 return bsl::pair<iterator, iterator>(iterator(first), iterator(last));
1842}
1843
1844template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1845inline
1846typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1847unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::erase(
1848 const_iterator position)
1849{
1850 BSLS_ASSERT(position != this->end());
1851
1852 return iterator(d_impl.remove(position.node()));
1853}
1854
1855template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1856inline
1857typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1858unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::erase(
1859 iterator position)
1860{
1861 return erase(const_iterator(position));
1862}
1863
1864template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1865typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
1866unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::erase(
1867 const key_type& key)
1868{ // As an alternative implementation, the table could return an extracted
1869 // "slice" list from the underlying table, and now need merely:
1870 // iterate each node, destroying the associated value
1871 // reclaim each node (potentially returning to a node-pool)
1872
1873 typedef ::BloombergLP::bslalg::BidirectionalNode<value_type> BNode;
1874
1875 if (HashTableLink *target = d_impl.find(key)) {
1876 target = d_impl.remove(target);
1877 size_type result = 1;
1878 while (target &&
1879 this->key_eq()(key, ListConfiguration::extractKey(
1880 static_cast<BNode *>(target)->value()))) {
1881 target = d_impl.remove(target);
1882 ++result;
1883 }
1884 return result; // RETURN
1885 }
1886
1887 return 0;
1888}
1889
1890template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1891typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1892unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::erase(
1893 const_iterator first,
1894 const_iterator last)
1895{
1896#if defined BDE_BUILD_TARGET_SAFE_2
1897 if (first != last) {
1898 iterator it = this->begin();
1899 const iterator end = this->end();
1900 for (; it != first; ++it) {
1901 BSLS_ASSERT(last != it);
1902 BSLS_ASSERT(end != it);
1903 }
1904 for (; it != last; ++it) {
1905 BSLS_ASSERT(end != it);
1906 }
1907 }
1908#endif
1909
1910 while (first != last) {
1911 first = this->erase(first);
1912 }
1913
1914 return iterator(first.node()); // convert from const_iterator
1915}
1916
1917template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1918inline
1919typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1920unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::insert(
1921 const value_type& value)
1922{
1923 return iterator(d_impl.insert(value));
1924}
1925
1926template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1927inline
1928typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::iterator
1929unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::insert(
1930 const_iterator hint,
1931 const value_type& value)
1932{
1933 return iterator(d_impl.insert(value, hint.node()));
1934}
1935
1936template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1937template <class INPUT_ITERATOR>
1938void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::insert(
1939 INPUT_ITERATOR first,
1940 INPUT_ITERATOR last)
1941{
1942 difference_type maxInsertions =
1943 ::BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
1944 if (0 < maxInsertions) {
1945 this->reserve(this->size() + maxInsertions);
1946 }
1947 else {
1948 BSLS_ASSERT_SAFE(0 == maxInsertions);
1949 }
1950
1951 while (first != last) {
1952 d_impl.emplace(*first);
1953 ++first;
1954 }
1955}
1956
1957#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1958template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1959inline
1960void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::insert(
1961 std::initializer_list<value_type> values)
1962{
1963 insert(values.begin(), values.end());
1964}
1965#endif
1966
1967template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1968inline
1969void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::max_load_factor(
1970 float newLoadFactor)
1971{
1972 d_impl.setMaxLoadFactor(newLoadFactor);
1973}
1974
1975template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1976inline
1977void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::rehash(
1978 size_type numBuckets)
1979{
1980 d_impl.rehashForNumBuckets(numBuckets);
1981}
1982
1983template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1984inline
1985void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::reserve(
1986 size_type numElements)
1987{
1988 d_impl.reserveForNumElements(numElements);
1989}
1990
1991template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
1992inline
1993void unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::swap(
1994 unordered_multimap& other)
1996 AllocatorTraits::is_always_equal::value &&
1997 bsl::is_nothrow_swappable<HASH>::value &&
1998 bsl::is_nothrow_swappable<EQUAL>::value)
1999{
2000 d_impl.swap(other.d_impl);
2001}
2002
2003// ACCESSORS
2004template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2005inline
2006ALLOCATOR
2007unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::get_allocator() const
2009{
2010 return d_impl.allocator();
2011}
2012
2013template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2014typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_iterator
2015unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::begin() const
2017{
2018 return const_iterator(d_impl.elementListRoot());
2019}
2020
2021template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2022inline
2023typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_iterator
2024unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::end() const
2026{
2027 return const_iterator();
2028}
2029
2030template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2031typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_iterator
2032unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::cbegin() const
2034{
2035 return const_iterator(d_impl.elementListRoot());
2036}
2037
2038template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2039inline
2040typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_iterator
2041unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::cend() const
2043{
2044 return const_iterator();
2045}
2046
2047template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2048inline
2049typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::
2050 const_local_iterator
2051unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::begin(
2052 size_type index) const
2053{
2054 BSLS_ASSERT_SAFE(index < this->bucket_count());
2055
2056 return const_local_iterator(&d_impl.bucketAtIndex(index));
2057}
2058
2059template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2060inline
2061typename
2062unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_local_iterator
2063unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::end(
2064 size_type index) const
2065{
2066 BSLS_ASSERT_SAFE(index < this->bucket_count());
2067
2068 return const_local_iterator(0, &d_impl.bucketAtIndex(index));
2069}
2070
2071template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2072inline
2073typename
2074unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_local_iterator
2075unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::cbegin(
2076 size_type index) const
2077{
2078 BSLS_ASSERT_SAFE(index < this->bucket_count());
2079
2080 return const_local_iterator(&d_impl.bucketAtIndex(index));
2081}
2082
2083template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2084inline
2085typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::
2086 const_local_iterator
2087unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::cend(
2088 size_type index) const
2089{
2090 BSLS_ASSERT_SAFE(index < this->bucket_count());
2091
2092 return const_local_iterator(0, &d_impl.bucketAtIndex(index));
2093}
2094
2095template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2096inline
2097typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2098unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::bucket(
2099 const key_type& key) const
2100{
2101 return d_impl.bucketIndexForKey(key);
2102}
2103
2104template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2105inline
2106typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2107unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::bucket_count() const
2109{
2110 return d_impl.numBuckets();
2111}
2112
2113template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2114inline
2115typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2116unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::bucket_size(
2117 size_type index) const
2118{
2119 BSLS_ASSERT_SAFE(index < this->bucket_count());
2120
2121 return d_impl.countElementsInBucket(index);
2122}
2123
2124template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2125typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>:: size_type
2126unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::count(
2127 const key_type& key) const
2128{
2129 typedef ::BloombergLP::bslalg::BidirectionalNode<value_type> BNode;
2130
2131 size_type result = 0;
2132 for (HashTableLink *cursor = d_impl.find(key);
2133 cursor;
2134 ++result, cursor = cursor->nextLink())
2135 {
2136 BNode *cursorNode = static_cast<BNode *>(cursor);
2137 if (!this->key_eq()(key,
2138 ListConfiguration::extractKey(cursorNode->value()))) {
2139
2140 break;
2141 }
2142 }
2143 return result;
2144}
2145
2146template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2147inline
2148typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::const_iterator
2149unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::find(
2150 const key_type& key) const
2151{
2152 return const_iterator(d_impl.find(key));
2153}
2154
2155
2156template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2157inline
2158bool unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::empty() const
2160{
2161 return 0 == d_impl.size();
2162}
2163
2164template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2165inline
2166typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2167unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size() const
2169{
2170 return d_impl.size();
2171}
2172
2173template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2174inline
2175typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2176unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::max_size() const
2178{
2179 return AllocatorTraits::max_size(get_allocator());
2180}
2181
2182template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2183inline
2184typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::hasher
2185unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::hash_function() const
2186{
2187 return d_impl.hasher();
2188}
2189
2190template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2191inline
2192typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::key_equal
2193unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::key_eq() const
2194{
2195 return d_impl.comparator();
2196}
2197
2198template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2199bsl::pair<typename unordered_multimap<KEY,
2200 VALUE,
2201 HASH,
2202 EQUAL,
2203 ALLOCATOR>::const_iterator,
2204 typename unordered_multimap<KEY,
2205 VALUE,
2206 HASH,
2207 EQUAL,
2208 ALLOCATOR>::const_iterator>
2209unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::equal_range(
2210 const key_type& key) const
2211{
2212 HashTableLink *first;
2213 HashTableLink *last;
2214 d_impl.findRange(&first, &last, key);
2215 return bsl::pair<const_iterator, const_iterator>(const_iterator(first),
2216 const_iterator(last));
2217}
2218
2219template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2220inline
2221typename unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::size_type
2222unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>:: max_bucket_count()
2223 const
2225{
2226 return d_impl.maxNumBuckets();
2227}
2228
2229template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2230inline
2231float unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::load_factor()
2232 const
2234{
2235 return d_impl.loadFactor();
2236}
2237
2238template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2239inline
2240float unordered_multimap<KEY, VALUE, HASH, EQUAL, ALLOCATOR>::max_load_factor()
2241 const
2243{
2244 return d_impl.maxLoadFactor();
2245}
2246
2247} // close namespace bsl
2248
2249// FREE OPERATORS
2250template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2251inline
2252bool bsl::operator==(
2255{
2256 return lhs.d_impl == rhs.d_impl;
2257}
2258
2259#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2260template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2261inline
2262bool bsl::operator!=(
2265{
2266 return !(lhs == rhs);
2267}
2268#endif
2269
2270// FREE FUNCTIONS
2271template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2272inline
2276{
2277 a.swap(b);
2278}
2279
2280// ============================================================================
2281// TYPE TRAITS
2282// ============================================================================
2283
2284// Type traits for STL *unordered* *associative* containers:
2285//: o An unordered associative container defines STL iterators.
2286//: o An unordered associative container is bitwise movable if both functors
2287//: and the allocator are bitwise movable.
2288//: o An unordered associative container uses 'bslma' allocators if the
2289//: (template parameter) type 'ALLOCATOR' is convertible from
2290//: 'bslma::Allocator*'.
2291
2292
2293
2294namespace bslalg {
2295
2296template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2297struct HasStlIterators<bsl::unordered_multimap<KEY,
2298 VALUE,
2299 HASH,
2300 EQUAL,
2301 ALLOCATOR> >
2303{};
2304
2305} // close namespace bslalg
2306
2307namespace bslma {
2308
2309template <class KEY, class VALUE, class HASH, class EQUAL, class ALLOCATOR>
2310struct UsesBslmaAllocator<bsl::unordered_multimap<KEY,
2311 VALUE,
2312 HASH,
2313 EQUAL,
2314 ALLOCATOR> >
2315: bsl::is_convertible<Allocator*, ALLOCATOR>::type
2316{};
2317
2318} // close namespace bslma
2319
2320namespace bslmf {
2321
2322template <class KEY, class MAPPED, class HASH, class EQUAL, class ALLOCATOR>
2323struct IsBitwiseMoveable<
2324 bsl::unordered_multimap<KEY, MAPPED, HASH, EQUAL, ALLOCATOR> >
2325 : ::BloombergLP::bslmf::IsBitwiseMoveable<BloombergLP::bslstl::HashTable<
2326 ::BloombergLP::bslstl::
2327 UnorderedMapKeyConfiguration<KEY, bsl::pair<const KEY, MAPPED> >,
2328 HASH,
2329 EQUAL,
2330 ALLOCATOR> >::type
2331{};
2332
2333}
2334
2335
2336#else // if ! defined(DEFINED_BSLSTL_UNORDEREDMULTIMAP_H)
2337# error Not valid except when included from bslstl_unorderedmultimap.h
2338#endif // ! defined(COMPILING_BSLSTL_UNORDEREDMULTIMAP_H)
2339
2340#endif // ! defined(INCLUDED_BSLSTL_UNORDEREDMULTIMAP_CPP03)
2341
2342// ----------------------------------------------------------------------------
2343// Copyright 2013 Bloomberg Finance L.P.
2344//
2345// Licensed under the Apache License, Version 2.0 (the "License");
2346// you may not use this file except in compliance with the License.
2347// You may obtain a copy of the License at
2348//
2349// http://www.apache.org/licenses/LICENSE-2.0
2350//
2351// Unless required by applicable law or agreed to in writing, software
2352// distributed under the License is distributed on an "AS IS" BASIS,
2353// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2354// See the License for the specific language governing permissions and
2355// limitations under the License.
2356// ----------------------------- END-OF-FILE ----------------------------------
2357
2358/** @} */
2359/** @} */
2360/** @} */
Definition bslma_bslallocator.h:580
Definition bslstl_pair.h:1210
Definition bslstl_unorderedmultimap.h:707
float max_load_factor() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2736
friend bool operator==(const unordered_multimap< KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2 > &, const unordered_multimap< KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2 > &)
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, pair< iterator, iterator > >::type equal_range(const LOOKUP_KEY &key)
Definition bslstl_unorderedmultimap.h:1091
unordered_multimap()
Definition bslstl_unorderedmultimap.h:1974
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2654
const value_type & const_reference
Definition bslstl_unorderedmultimap.h:763
EQUAL key_eq() const
Definition bslstl_unorderedmultimap.h:2689
float load_factor() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2727
KEY key_type
Definition bslstl_unorderedmultimap.h:755
ALLOCATOR allocator_type
Definition bslstl_unorderedmultimap.h:760
AllocatorTraits::const_pointer const_pointer
Definition bslstl_unorderedmultimap.h:768
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2275
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2672
void reserve(size_type numElements)
Definition bslstl_unorderedmultimap.h:2481
HASH hash_function() const
Definition bslstl_unorderedmultimap.h:2681
::BloombergLP::bslstl::HashTableIterator< value_type, difference_type > iterator
Definition bslstl_unorderedmultimap.h:771
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, iterator >::type find(const LOOKUP_KEY &key)
Definition bslstl_unorderedmultimap.h:1157
unordered_multimap &operator=(BloombergLP::bslmf::MovableRef< unordered_multimap > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2266
size_type bucket(const key_type &key) const
Definition bslstl_unorderedmultimap.h:2594
value_type & reference
Definition bslstl_unorderedmultimap.h:762
HASH hasher
Definition bslstl_unorderedmultimap.h:758
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2528
void swap(unordered_multimap &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:1360
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2537
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, size_type >::type count(const LOOKUP_KEY &key) const
Definition bslstl_unorderedmultimap.h:1451
::BloombergLP::bslstl::HashTableIterator< const value_type, difference_type > const_iterator
Definition bslstl_unorderedmultimap.h:774
EQUAL key_equal
Definition bslstl_unorderedmultimap.h:759
size_type max_bucket_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2718
size_type bucket_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2603
iterator insert(const value_type &value)
Definition bslstl_unorderedmultimap.h:2416
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this unordered multimap.
Definition bslstl_unorderedmultimap.h:2663
size_type erase(const key_type &key)
Definition bslstl_unorderedmultimap.h:2362
bool contains(const key_type &key) const
Definition bslstl_unorderedmultimap.h:2312
::BloombergLP::bslstl::HashTableBucketIterator< const value_type, difference_type > const_local_iterator
Definition bslstl_unorderedmultimap.h:780
AllocatorTraits::difference_type difference_type
Definition bslstl_unorderedmultimap.h:766
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition bslstl_unorderedmultimap.h:2254
::BloombergLP::bslstl::HashTableBucketIterator< value_type, difference_type > local_iterator
Definition bslstl_unorderedmultimap.h:777
AllocatorTraits::pointer pointer
Definition bslstl_unorderedmultimap.h:767
bsl::pair< const KEY, VALUE > value_type
Definition bslstl_unorderedmultimap.h:757
AllocatorTraits::size_type size_type
Definition bslstl_unorderedmultimap.h:765
void rehash(size_type numBuckets)
Definition bslstl_unorderedmultimap.h:2473
iterator emplace(Args &&... args)
Definition bslstl_unorderedmultimap.h:2243
size_type bucket_size(size_type index) const
Definition bslstl_unorderedmultimap.h:2612
void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedmultimap.h:2304
VALUE mapped_type
Definition bslstl_unorderedmultimap.h:756
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
void swap(OptionValue &a, OptionValue &b)
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
Definition bdlb_printmethods.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4126
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
bool operator==(const memory_resource &a, const memory_resource &b)
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdldfp_decimal.h:5188
Definition bslma_allocatortraits.h:1061
BloombergLP::bslma::AllocatorTraits_ConstPointerType< ALLOCATOR >::type const_pointer
Definition bslma_allocatortraits.h:1152
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR >::type size_type
Definition bslma_allocatortraits.h:1165
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR >::type pointer
Definition bslma_allocatortraits.h:1149
BloombergLP::bslma::AllocatorTraits_DifferenceType< ALLOCATOR >::type difference_type
Definition bslma_allocatortraits.h:1162
Definition bslstl_equalto.h:311
Definition bslstl_hash.h:498
Definition bslmf_isconvertible.h:867
t_TYPE type
Definition bslmf_typeidentity.h:216