BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlc_flathashmap.h
Go to the documentation of this file.
1/// @file bdlc_flathashmap.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlc_flathashmap.h -*-C++-*-
8#ifndef INCLUDED_BDLC_FLATHASHMAP
9#define INCLUDED_BDLC_FLATHASHMAP
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlc_flathashmap bdlc_flathashmap
15/// @brief Provide an open-addressed unordered map container.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlc
19/// @{
20/// @addtogroup bdlc_flathashmap
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlc_flathashmap-purpose"> Purpose</a>
25/// * <a href="#bdlc_flathashmap-classes"> Classes </a>
26/// * <a href="#bdlc_flathashmap-description"> Description </a>
27/// * <a href="#bdlc_flathashmap-performance-caveats"> Performance Caveats </a>
28/// * <a href="#bdlc_flathashmap-interface-differences-with-unordered_map"> Interface Differences with unordered_map </a>
29/// * <a href="#bdlc_flathashmap-load-factor-and-resizing"> Load Factor and Resizing </a>
30/// * <a href="#bdlc_flathashmap-requirements-on-key-hash-and-equal"> Requirements on KEY, HASH, and EQUAL </a>
31/// * <a href="#bdlc_flathashmap-iterator-pointer-and-reference-invalidation"> Iterator, Pointer, and Reference Invalidation </a>
32/// * <a href="#bdlc_flathashmap-exception-safety"> Exception Safety </a>
33/// * <a href="#bdlc_flathashmap-move-semantics-in-c-03"> Move Semantics in C++03 </a>
34/// * <a href="#bdlc_flathashmap-usage"> Usage </a>
35/// * <a href="#bdlc_flathashmap-example-1-gathering-document-statistics"> Example 1: Gathering Document Statistics </a>
36///
37/// # Purpose {#bdlc_flathashmap-purpose}
38/// Provide an open-addressed unordered map container.
39///
40/// # Classes {#bdlc_flathashmap-classes}
41///
42/// - bdlc::FlatHashMap: open-addressed unordered map container
43///
44/// @see bdlc_flathashtable, bdlc_flathashset
45///
46/// # Description {#bdlc_flathashmap-description}
47/// This component defines a single class template,
48/// `bdlc::FlatHashMap`, that implements an open-addressed unordered map of
49/// items with unique keys.
50///
51/// Unordered maps are useful in situations when there is no meaningful way to
52/// order key values, when the order of the keys is irrelevant to the problem
53/// domain, or (even if there is a meaningful ordering) the value of ordering
54/// the keys is outweighed by the higher performance provided by unordered maps
55/// (compared to ordered maps). On platforms that support relevant SIMD
56/// instructions (e.g., SSE2), `bdlc::FlatHashMap` generally exhibits better
57/// performance than `bsl::unordered_map`.
58///
59/// An instantiation of `bdlc::FlatHashMap` is an allocator-aware,
60/// value-semantic type whose salient attributes are the collection of
61/// `KEY-VALUE` pairs contained, without regard to order. An instantiation may
62/// be provided with custom hash and key-equality functors, but those are not
63/// salient attributes. In particular, when comparing element values for
64/// equality between two different `bdlc::FlatHashMap` objects, the elements are
65/// compared using `operator==`.
66///
67/// The implemented data structure is inspired by Google's `flat_hash_map`
68/// CppCon presentations (available on YouTube). The implementation draws from
69/// Google's open source `raw_hash_set.h` file at:
70/// https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal.
71///
72/// ## Performance Caveats {#bdlc_flathashmap-performance-caveats}
73///
74///
75/// `bdlc::FlatHashMap` is recommended for Intel platforms *only* (i.e., Linux
76/// and Windows, and pre-ARM Macs); on platforms using other processors (i.e.,
77/// Sun and AIX), `bdlc::FlatHashMap` may have slower performance than
78/// `bsl::unordered_map`. However, note that `bdlc::FlatHashMap` will use
79/// significantly less memory than `bsl::unordered_map` on *all* platforms.
80/// Given the Intel-only performance caveat, it is recommended to benchmark
81/// before using `bdlc::FlatHashMap` -- particularly on non-Intel production
82/// environments.
83///
84/// ## Interface Differences with unordered_map {#bdlc_flathashmap-interface-differences-with-unordered_map}
85///
86///
87/// A `bdlc::FlatHashMap` meets most of the requirements of an unordered
88/// associative container with forward iterators in the C++11 Standard [23.2.5].
89/// It does not have the bucket interface, and locations of elements may change
90/// when the container is modified (and therefore iterators become invalid too).
91/// Allocator use follows BDE style, and the various allocator propagation
92/// attributes are not present (e.g., the allocator trait
93/// `propagate_on_container_copy_assignment`). The maximum load factor of the
94/// container (the ratio of size to capacity) is maintained by the container
95/// itself and is not settable (the maximum load factor is implementation
96/// defined and fixed).
97///
98/// ## Load Factor and Resizing {#bdlc_flathashmap-load-factor-and-resizing}
99///
100///
101/// An invariant of `bdlc::FlatHashMap` is that
102/// `0 <= load_factor() <= max_load_factor() <= 1.0`. Any operation that would
103/// result in `load_factor() > max_load_factor()` for a `bdlc::FlatHashMap`
104/// causes the capacity to increase. This resizing allocates new memory, copies
105/// or moves all elements to the new memory, and reclaims the original memory.
106/// The transfer of elements involves rehashing each element to determine its
107/// new location. As such, all iterators, pointers, and references to elements
108/// of the `bdlc::FlatHashMap` are invalidated on a resize.
109///
110/// ## Requirements on KEY, HASH, and EQUAL {#bdlc_flathashmap-requirements-on-key-hash-and-equal}
111///
112///
113/// The template parameter type `KEY` must be copy or move constructible. The
114/// template parameter types `HASH` and `EQUAL` must be default and copy
115/// constructible function objects.
116///
117/// `HASH` must support a function-call operator compatible with the following
118/// statements for an object `key` of type `KEY`:
119/// @code
120/// HASH hash;
121/// bsl::size_t result = hash(key);
122/// @endcode
123///
124/// `EQUAL` must support a function-call operator compatible with the
125/// following statements for objects `key1` and `key2` of type `KEY`:
126/// @code
127/// EQUAL equal;
128/// bool result = equal(key1, key2);
129/// @endcode
130/// where the definition of the called function defines an equivalence
131/// relationship on keys that is both reflexive and transitive.
132///
133/// `HASH` and `EQUAL` function objects are further constrained: if the
134/// comparator determines that two values are equal, the hasher must produce the
135/// same hash value for each.
136///
137/// ## Iterator, Pointer, and Reference Invalidation {#bdlc_flathashmap-iterator-pointer-and-reference-invalidation}
138///
139///
140/// Any change in capacity of a `bdlc::FlatHashMap` invalidates all pointers,
141/// references, and iterators. A `bdlc::FlatHashMap` manipulator that erases an
142/// element invalidates all pointers, references, and iterators to the erased
143/// element.
144///
145/// ## Exception Safety {#bdlc_flathashmap-exception-safety}
146///
147///
148/// A `bdlc::FlatHashMap` is exception neutral, and all of the methods of
149/// `bdlc::FlatHashMap` provide the basic exception safety guarantee (see
150/// {@ref bsldoc_glossary |Basic Guarantee}).
151///
152/// ## Move Semantics in C++03 {#bdlc_flathashmap-move-semantics-in-c-03}
153///
154///
155/// Move-only types are supported by `bdlc::FlatHashMap` on C++11, and later,
156/// platforms only (where `BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES` is defined),
157/// and are not supported on C++03 platforms. Unfortunately, in C++03, there
158/// are user-defined types where a `bslmf::MovableRef` will not safely degrade
159/// to an lvalue reference when a move constructor is not available (types
160/// providing a constructor template taking any type), so
161/// `bslmf::MovableRefUtil::move` cannot be used directly on a user-supplied
162/// template parameter type.
163///
164/// ## Usage {#bdlc_flathashmap-usage}
165///
166///
167/// In this section we show intended use of this component.
168///
169/// ### Example 1: Gathering Document Statistics {#bdlc_flathashmap-example-1-gathering-document-statistics}
170///
171///
172/// Suppose one wished to gather statistics on the words appearing in a large
173/// set of documents on disk or in a database. Gathering those statistics is
174/// intrusive (as one is competing for access to the documents with the regular
175/// users) and must be done as quickly as possible. Moreover, the set of unique
176/// words appearing in those documents may be high. The English language has in
177/// excess of a million words (albeit many appear infrequently), and, if the
178/// documents contain serial numbers, or Social Security numbers, or chemical
179/// formulas, etc., then the `O[log(n)]` insertion time of ordered maps may well
180/// be inadequate. An unordered map, having an `O[1]` typical insertion cost,
181/// is a viable alternative.
182///
183/// This example illustrates the use of `bdlc::FlatHashMap` to gather one simple
184/// statistic (counts of unique words) on a portion of a single document. To
185/// avoid irrelevant details of acquiring the data, the data is stored in static
186/// arrays:
187/// @code
188/// static char document[] =
189/// " IN CONGRESS, July 4, 1776.\n"
190/// "\n"
191/// " The unanimous Declaration of the thirteen united States of America,\n"
192/// "\n"
193/// " When in the Course of human events, it becomes necessary for one\n"
194/// " people to dissolve the political bands which have connected them with\n"
195/// " another, and to assume among the powers of the earth, the separate\n"
196/// " and equal station to which the Laws of Nature and of Nature's G-d\n"
197/// " entitle them, a decent respect to the opinions of mankind requires\n"
198/// " that they should declare the causes which impel them to the\n"
199/// " separation. We hold these truths to be self-evident, that all men\n"
200/// " are created equal, that they are endowed by their Creator with\n"
201/// " certain unalienable Rights, that among these are Life, Liberty and\n"
202/// " the pursuit of Happiness. That to secure these rights, Governments\n"
203/// " are instituted among Men, deriving their just powers from the consent\n"
204/// " of the governed, That whenever any Form of Government becomes\n";
205/// @endcode
206/// First, we define an alias to make our code more comprehensible:
207/// @code
208/// typedef bdlc::FlatHashMap<bsl::string, int> WordTally;
209/// @endcode
210/// Next, we create an (empty) flat hash map to hold our word tallies:
211/// @code
212/// WordTally wordTally;
213/// @endcode
214/// Then, we define the set of characters that define word boundaries:
215/// @code
216/// const char *delimiters = " \n\t,:;.()[]?!/";
217/// @endcode
218/// Next, we extract the words from our document. Note that `strtok` modifies
219/// the document array (which was not made `const`).
220///
221/// For each iteration of the loop, a map entry matching the key value parsed by
222/// `strtok` is obtained. On the first occurrence of a word, the map has no
223/// such entry, so one is created with a default value of the mapped value (0,
224/// just what we want in this case) and inserted into the map where it is found
225/// on any subsequent occurrences of the word. The `operator[]` method returns
226/// a reference providing modifiable access to the mapped value. Here, we apply
227/// the `++` operator to that reference to maintain a tally for the word:
228/// @code
229/// for (char *cur = strtok(document, delimiters);
230/// cur;
231/// cur = strtok(NULL, delimiters)) {
232/// ++wordTally[bsl::string(cur)];
233/// }
234/// @endcode
235/// Now that the data has been (quickly) gathered, we can indulge in analysis
236/// that is more time consuming. For example, we can define a comparison
237/// function, copy the data to another container (e.g., `bsl::vector`), sort the
238/// entries, and determine the 10 most commonly used words in the given
239/// documents:
240/// @code
241/// typedef bsl::pair<bsl::string, int> WordTallyEntry;
242/// // Assignable equivalent to 'WordTally::value_type'. Note that
243/// // 'bsl::vector' requires assignable types.
244///
245/// struct WordTallyEntryCompare {
246/// static bool lessThan(const WordTallyEntry& a,
247/// const WordTallyEntry& b) {
248/// return a.second < b.second;
249/// }
250/// static bool greaterThan(const WordTallyEntry& a,
251/// const WordTallyEntry& b) {
252/// return a.second > b.second;
253/// }
254/// };
255///
256/// bsl::vector<WordTallyEntry> array(wordTally.cbegin(), wordTally.cend());
257///
258/// assert(10 <= array.size());
259///
260/// bsl::partial_sort(array.begin(),
261/// array.begin() + 10,
262/// array.end(),
263/// WordTallyEntryCompare::greaterThan);
264/// @endcode
265/// Notice that @ref partial_sort suffices here since we seek only the 10 most used
266/// words, not a complete distribution of word counts.
267///
268/// Finally, we print the sorted portion of `array`:
269/// @code
270/// for (bsl::vector<WordTallyEntry>::const_iterator cur = array.begin(),
271/// end = cur + 10;
272/// end != cur; ++cur) {
273/// printf("%-10s %4d\n", cur->first.c_str(), cur->second);
274/// }
275/// @endcode
276/// and standard output shows:
277/// @code
278/// the 13
279/// of 10
280/// to 7
281/// that 4
282/// are 4
283/// and 4
284/// which 3
285/// these 3
286/// them 3
287/// among 3
288/// @endcode
289/// @}
290/** @} */
291/** @} */
292
293/** @addtogroup bdl
294 * @{
295 */
296/** @addtogroup bdlc
297 * @{
298 */
299/** @addtogroup bdlc_flathashmap
300 * @{
301 */
302
303#include <bdlscm_version.h>
304
305#include <bdlc_flathashtable.h>
306
308#include <bslalg_swaputil.h>
309
311
312#include <bslim_printer.h>
313
314#include <bslma_allocator.h>
318
319#include <bslmf_addconst.h>
320#include <bslmf_enableif.h>
321#include <bslmf_isconvertible.h>
322#include <bslmf_movableref.h>
323#include <bslmf_util.h> // 'forward(V)'
324
325#include <bsls_assert.h>
327#include <bsls_objectbuffer.h>
328#include <bsls_platform.h>
329#include <bsls_util.h> // 'forward<T>(V)'
330
331#include <bslstl_equalto.h>
332#include <bslstl_hash.h>
333#include <bslstl_stdexceptutil.h>
334
335#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
336#include <bsl_initializer_list.h>
337#endif
338#include <bsl_cstddef.h>
339#include <bsl_ostream.h>
340#include <bsl_utility.h>
341
342#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
343// Include version that can be compiled with C++03
344// Generated on Tue Feb 13 08:49:03 2024
345// Command line: sim_cpp11_features.pl bdlc_flathashmap.h
346# define COMPILING_BDLC_FLATHASHMAP_H
347# include <bdlc_flathashmap_cpp03.h>
348# undef COMPILING_BDLC_FLATHASHMAP_H
349#else
350
351#if defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
352#include <bsl_type_traits.h>
353
354 #ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
355 #error Rvalue references curiously absent despite native 'type_traits'.
356 #endif
357
358#endif
359
360
361namespace bdlc {
362
363// FORWARD DECLARATIONS
364template <class KEY,
365 class VALUE,
367 class EQUAL = bsl::equal_to<KEY> >
368class FlatHashMap;
369
370template <class KEY, class VALUE, class HASH, class EQUAL>
371bool operator==(const FlatHashMap<KEY, VALUE, HASH, EQUAL> &lhs,
373
374template <class KEY, class VALUE, class HASH, class EQUAL>
375bool operator!=(const FlatHashMap<KEY, VALUE, HASH, EQUAL> &lhs,
377
378template <class KEY, class VALUE, class HASH, class EQUAL>
381
382 // ============================
383 // struct FlatHashMap_EntryUtil
384 // ============================
385
386/// This templated utility provides methods to construct an `ENTRY` and a
387/// method to extract the key from an `ENTRY`.
388template <class KEY, class VALUE, class ENTRY>
390{
391 // CLASS METHODS
392#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
393 /// Load into the specified `entry` the `ENTRY` value constructed from
394 /// specified `args`, using the specified `allocator` to supply memory.
395 /// `allocator` is ignored if the (template parameter) type `ENTRY` is
396 /// not allocator aware.
397 template <class... ARGS>
398 static void construct(
399 ENTRY *entry,
400 bslma::Allocator *allocator,
401 ARGS&&... args);
402#endif
403
404 /// Load into the specified `entry` the `ENTRY` value comprised of the
405 /// specified `key` and a default constructed `VALUE`, using the
406 /// specified `allocator` to supply memory. `allocator` is ignored if
407 /// the (template parameter) type `ENTRY` is not allocator aware.
408 template <class KEY_TYPE>
409 static void constructFromKey(
410 ENTRY *entry,
411 bslma::Allocator *allocator,
413
414 /// Return the key of the specified `entry`.
415 static const KEY& key(const ENTRY& entry);
416};
417
418 // =================
419 // class FlatHashMap
420 // =================
421
422/// This class template implements a value-semantic container type holding
423/// an unordered map of `KEY-VALUE` pairs having unique keys that provides a
424/// mapping from keys of (template parameter) type `KEY` to their associated
425/// mapped values of (template parameter) type `VALUE`. The (template
426/// parameter) type `HASH` is a functor providing the hash value for `KEY`.
427/// The (template parameter) type `EQUAL` is a functor providing the
428/// equality function for two `KEY` values. See {Requirements on `KEY`,
429/// `HASH`, and `EQUAL`} for more information.
430///
431/// See @ref bdlc_flathashmap
432template <class KEY, class VALUE, class HASH, class EQUAL>
434
435 private:
436 // PRIVATE TYPES
437
438 /// This is the underlying implementation class.
439 typedef FlatHashTable<KEY,
442 VALUE,
444 HASH,
445 EQUAL> ImplType;
446
447 // FRIENDS
448 friend bool operator==<>(const FlatHashMap&, const FlatHashMap&);
449 friend bool operator!=<>(const FlatHashMap&, const FlatHashMap&);
450
451 // The following verbose declaration is required by the xlC 12.1 compiler.
452 template <class K, class V, class H, class E>
454
455 public:
456 // PUBLIC TYPES
458
459 typedef KEY key_type;
460 typedef VALUE mapped_type;
461 typedef bsl::size_t size_type;
462 typedef bsl::ptrdiff_t difference_type;
463 typedef EQUAL key_compare;
464 typedef HASH hasher;
468 typedef const value_type* const_pointer;
469 typedef typename ImplType::iterator iterator;
471
472 private:
473 // DATA
474 ImplType d_impl; // underlying flat hash table used by this flat hash map
475
476 public:
477 // CREATORS
478
479 FlatHashMap();
480 explicit FlatHashMap(bslma::Allocator *basicAllocator);
481 explicit FlatHashMap(bsl::size_t capacity);
482 FlatHashMap(bsl::size_t capacity, bslma::Allocator *basicAllocator);
483 FlatHashMap(bsl::size_t capacity,
484 const HASH& hash,
485 bslma::Allocator *basicAllocator = 0);
486 /// Create an empty `FlatHashMap` object. Optionally specify a
487 /// `capacity` indicating the minimum initial size of the underlying
488 /// array of entries of this container. If `capacity` is not supplied
489 /// or is 0, no memory is allocated. Optionally specify a `hash`
490 /// functor used to generate the hash values associated with the keys of
491 /// elements in this container. If `hash` is not supplied, a
492 /// default-constructed object of the (template parameter) type `HASH`
493 /// is used. Optionally specify an equality functor `equal` used to
494 /// determine whether the keys of two elements are equivalent. If
495 /// `equal` is not supplied, a default-constructed object of the
496 /// (template parameter) type `EQUAL` is used. Optionally specify a
497 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
498 /// supplied or is 0, the currently installed default allocator is used.
499 FlatHashMap(bsl::size_t capacity,
500 const HASH& hash,
501 const EQUAL& equal,
502 bslma::Allocator *basicAllocator = 0);
503
504 /// Create a `FlatHashMap` object initialized by insertion of the values
505 /// from the input iterator range specified by `first` through `last`
506 /// (including `first`, excluding `last`). Optionally specify a
507 /// `capacity` indicating the minimum initial size of the underlying
508 /// array of entries of this container. If `capacity` is not supplied
509 /// or is 0, no memory is allocated. Optionally specify a `hash`
510 /// functor used to generate hash values associated with the keys of the
511 /// elements in this container. If `hash` is not supplied, a
512 /// default-constructed object of the (template parameter) type `HASH`
513 /// is used. Optionally specify an equality functor `equal` used to
514 /// determine whether the keys of two elements are equivalent. If
515 /// `equal` is not supplied, a default-constructed object of the
516 /// (template parameter) type `EQUAL` is used. Optionally specify a
517 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
518 /// supplied or is 0, the currently installed default allocator is used.
519 /// The behavior is undefined unless `first` and `last` refer to a
520 /// sequence of valid values where `first` is at a position at or before
521 /// `last`. Note that if a member of the input sequence has an
522 /// equivalent key to an earlier member, the later member will not be
523 /// inserted.
524 template <class INPUT_ITERATOR>
525 FlatHashMap(INPUT_ITERATOR first,
526 INPUT_ITERATOR last,
527 bslma::Allocator *basicAllocator = 0);
528 template <class INPUT_ITERATOR>
529 FlatHashMap(INPUT_ITERATOR first,
530 INPUT_ITERATOR last,
531 bsl::size_t capacity,
532 bslma::Allocator *basicAllocator = 0);
533 template <class INPUT_ITERATOR>
534 FlatHashMap(INPUT_ITERATOR first,
535 INPUT_ITERATOR last,
536 bsl::size_t capacity,
537 const HASH& hash,
538 bslma::Allocator *basicAllocator = 0);
539 template <class INPUT_ITERATOR>
540 FlatHashMap(INPUT_ITERATOR first,
541 INPUT_ITERATOR last,
542 bsl::size_t capacity,
543 const HASH& hash,
544 const EQUAL& equal,
545 bslma::Allocator *basicAllocator = 0);
546
547#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
548 FlatHashMap(bsl::initializer_list<value_type> values,
549 bslma::Allocator *basicAllocator = 0);
550 FlatHashMap(bsl::initializer_list<value_type> values,
551 bsl::size_t capacity,
552 bslma::Allocator *basicAllocator = 0);
553 FlatHashMap(bsl::initializer_list<value_type> values,
554 bsl::size_t capacity,
555 const HASH& hash,
556 bslma::Allocator *basicAllocator = 0);
557 /// Create a `FlatHashMap` object initialized by insertion of the
558 /// specified `values`. Optionally specify a `capacity` indicating the
559 /// minimum initial size of the underlying array of entries of this
560 /// container. If `capacity` is not supplied or is 0, no memory is
561 /// allocated. Optionally specify a `hash` functor used to generate
562 /// hash values associated with the keys of elements in this container.
563 /// If `hash` is not supplied, a default-constructed object of the
564 /// (template parameter) type `HASH` is used. Optionally specify an
565 /// equality functor `equal` used to determine whether the keys of two
566 /// elements are equivalent. If `equal` is not supplied, a
567 /// default-constructed object of the (template parameter) type `EQUAL`
568 /// is used. Optionally specify a `basicAllocator` used to supply
569 /// memory. If `basicAllocator` is not supplied or is 0, the currently
570 /// installed default allocator is used. Note that if a member of
571 /// `values` has an equivalent key to an earlier member, the later
572 /// member will not be inserted.
573 FlatHashMap(bsl::initializer_list<value_type> values,
574 bsl::size_t capacity,
575 const HASH& hash,
576 const EQUAL& equal,
577 bslma::Allocator *basicAllocator = 0);
578#endif
579
580 /// Create a `FlatHashMap` object having the same value, hasher, and
581 /// equality comparator as the specified `original` object. Optionally
582 /// specify a `basicAllocator` used to supply memory. If
583 /// `basicAllocator` is not specified or is 0, the currently installed
584 /// default allocator is used.
585 FlatHashMap(const FlatHashMap& original,
586 bslma::Allocator *basicAllocator = 0);
587
588 /// Create a `FlatHashMap` object having the same value, hasher,
589 /// equality comparator, and allocator as the specified `original`
590 /// object. The contents of `original` are moved (in constant time) to
591 /// this object, `original` is left in a (valid) unspecified state, and
592 /// no exceptions will be thrown.
594
595 /// Create a `FlatHashMap` object having the same value, hasher, and
596 /// equality comparator as the specified `original` object, using the
597 /// specified `basicAllocator` to supply memory. If `basicAllocator` is
598 /// 0, the currently installed default allocator is used. The allocator
599 /// of `original` remains unchanged. If `original` and the newly
600 /// created object have the same allocator then the contents of
601 /// `original` are moved (in constant time) to this object, `original`
602 /// is left in a (valid) unspecified state, and no exceptions will be
603 /// thrown; otherwise, `original` is unchanged (and an exception may be
604 /// thrown).
606 bslma::Allocator *basicAllocator);
607
608 /// Destroy this object and each of its elements.
609 ~FlatHashMap();
610
611 // MANIPULATORS
612
613 /// Assign to this object the value, hasher, and equality functor of the
614 /// specified `rhs` object, and return a reference providing modifiable
615 /// access to this object.
616 FlatHashMap& operator=(const FlatHashMap& rhs);
617
618 /// Assign to this object the value, hasher, and equality comparator of
619 /// the specified `rhs` object, and return a reference providing
620 /// modifiable access to this object. If this object and `rhs` use the
621 /// same allocator the contents of `rhs` are moved (in constant time) to
622 /// this object. `rhs` is left in a (valid) unspecified state.
624
625#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
626 /// Assign to this object the value resulting from first clearing this
627 /// map and then inserting each object in the specified `values`
628 /// initializer list, ignoring those objects having a value whose key is
629 /// equivalent to that which appears earlier in the list; return a
630 /// reference providing modifiable access to this object. This method
631 /// requires that the (template parameter) type `KEY` be
632 /// `copy-insertable` into this map (see {Requirements on `KEY`, `HASH`,
633 /// and `EQUAL`}).
634 FlatHashMap& operator=(bsl::initializer_list<value_type> values);
635#endif
636
637 /// Return a reference providing modifiable access to the mapped value
638 /// associated with the specified `key` in this map. If this map does
639 /// not already contain an element having `key`, insert an element with
640 /// the `key` and a default-constructed `VALUE`, and return a reference
641 /// to the newly mapped value. If `key` is movable, `key` is left in a
642 /// (valid) unspecified state.
643 template <class KEY_TYPE>
644 VALUE& operator[](BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) key);
645
646 /// Return a reference providing modifiable access to the mapped value
647 /// associated with the specified `key` in this map, if such an entry
648 /// exists; otherwise throw a `std::out_of_range` exception. Note that
649 /// this method is not exception-neutral.
650 VALUE& at(const KEY& key);
651
652 /// Remove all elements from this map. Note that this map will be empty
653 /// after calling this method, but allocated memory may be retained for
654 /// future use. See the `capacity` method.
655 void clear();
656
657 /// Return a pair of iterators defining the sequence of modifiable
658 /// elements in this map having the specified `key`, where the first
659 /// iterator is positioned at the start of the sequence and the second
660 /// iterator is positioned one past the end of the sequence. If this
661 /// map contains no elements having a key equivalent to `key`, then the
662 /// two returned iterators will have the same value. Note that since a
663 /// map maintains unique keys, the range will contain at most one
664 /// element.
666
667#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
668 /// Insert into this map a newly-created `value_type` object,
669 /// constructed by forwarding `get_allocator()` (if required) and the
670 /// specified (variable number of) `args` to the corresponding
671 /// constructor of `value_type`, if a key equivalent to such a value
672 /// does not already exist in this map; otherwise, this method has no
673 /// effect (other than possibly creating a temporary `value_type`
674 /// object). Return a pair whose `first` member is an iterator
675 /// referring to the (possibly newly created and inserted) object in
676 /// this map whose key is equivalent to that of an object constructed
677 /// from `args`, and whose `second` member is `true` if a new value was
678 /// inserted, and `false` if an equivalent key was already present.
679 /// This method requires that the (template parameter) types `KEY` and
680 /// `VALUE` both be `emplace-constructible` from `args` (see
681 /// {Requirements on `value_type`}).
682 template <class... ARGS>
684
685 /// Insert into this map a newly-created `value_type` object,
686 /// constructed by forwarding `get_allocator()` (if required) and the
687 /// specified (variable number of) `args` to the corresponding
688 /// constructor of `value_type`, if a key equivalent to such a value
689 /// does not already exist in this map; otherwise, this method has no
690 /// effect (other than possibly creating a temporary `value_type`
691 /// object). Return an iterator referring to the (possibly newly
692 /// created and inserted) object in this map whose key is equivalent to
693 /// that of an object constructed from `args`. The average and worst
694 /// case complexity of this operation is not affected by the specified
695 /// `hint`. This method requires that the (template parameter) types
696 /// `KEY` and `VALUE` both be `emplace-constructible` from `args` (see
697 /// {Requirements on `value_type`}). The behavior is undefined unless
698 /// `hint` is an iterator in the range `[begin() .. end()]` (both
699 /// endpoints included). Note that `hint` is ignored (other than
700 /// possibly asserting its validity in some build modes).
701 template <class... ARGS>
702 iterator emplace_hint(const_iterator hint, ARGS&&... args);
703#endif
704
705 /// Remove from this map the element whose key is equal to the specified
706 /// `key`, if it exists, and return 1; otherwise (there is no element
707 /// having `key` in this map), return 0 with no other effect. This
708 /// method invalidates all iterators and references to the removed
709 /// element.
710 bsl::size_t erase(const KEY& key);
711
712 iterator erase(const_iterator position);
713 /// Remove from this map the element at the specified `position`, and
714 /// return an iterator referring to the modifiable element immediately
715 /// following the removed element, or to the past-the-end position if
716 /// the removed element was the last element in the sequence of elements
717 /// maintained by this map. This method invalidates all iterators and
718 /// references to the removed element. The behavior is undefined unless
719 /// `position` refers to an element in this map.
720 iterator erase(iterator position);
721
722 /// Remove from this map the elements starting at the specified `first`
723 /// position up to, but not including, the specified `last` position,
724 /// and return an iterator referencing the same element as `last`. This
725 /// method invalidates all iterators and references to the removed
726 /// elements. The behavior is undefined unless `first` and `last` are
727 /// valid iterators on this map, and the `first` position is at or
728 /// before the `last` position in the iteration sequence provided by
729 /// this container.
731
732 /// Return an iterator referring to the modifiable element in this map
733 /// having the specified `key`, or `end()` if no such entry exists in
734 /// this map.
735 iterator find(const KEY& key);
736
737#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
738 template <class VALUE_TYPE>
740#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
741 template <class VALUE_TYPE>
744#else
745 /// Insert the specified `value` into this map if the key of `value`
746 /// does not already exist in this map; otherwise, this method has no
747 /// effect. Return a `pair` whose `first` member is an iterator
748 /// referring to the (possibly newly inserted) modifiable element in
749 /// this map whose key is equivalent to that of the element to be
750 /// inserted, and whose `second` member is `true` if a new element was
751 /// inserted, and `false` if an element with an equivalent key was
752 /// already present.
753 template <class VALUE_TYPE>
754 typename bsl::enable_if<bsl::is_constructible<value_type,
755 VALUE_TYPE&&>::value,
757#endif
759 {
760 // Note that some compilers require functions declared with 'enable_if'
761 // to be defined inline.
762
763 return d_impl.insert(BSLS_COMPILERFEATURES_FORWARD(VALUE_TYPE, value));
764 }
765
766#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
767 template <class VALUE_TYPE>
769#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
770 template <class VALUE_TYPE>
772 iterator>::type
773#else
774 /// Insert the specified `value` into this map if the key of `value`
775 /// does not already exist in this map; otherwise, this method has no
776 /// effect. Return an iterator referring to the (possibly newly
777 /// inserted) modifiable element in this map whose key is equivalent to
778 /// that of the element to be inserted. The supplied `const_iterator`
779 /// is ignored.
780 template <class VALUE_TYPE>
781 typename bsl::enable_if<bsl::is_constructible<value_type,
782 VALUE_TYPE&&>::value,
783 iterator>::type
784#endif
786 BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE) value)
787 {
788 // Note that some compilers require functions declared with 'enable_if'
789 // to be defined inline.
790
791 return d_impl.insert(BSLS_COMPILERFEATURES_FORWARD(VALUE_TYPE,
792 value)).first;
793 }
794
795 /// Insert into this map the value of each element in the input iterator
796 /// range specified by `first` through `last` (including `first`,
797 /// excluding `last`). The behavior is undefined unless `first` and
798 /// `last` refer to a sequence of valid values where `first` is at a
799 /// position at or before `last`. Note that if the key of a member of
800 /// the input sequence is equivalent to the key of an earlier member,
801 /// the later member will not be inserted.
802 template <class INPUT_ITERATOR>
803 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
804
805#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
806 /// Insert into this map an element having the value of each object in
807 /// the specified `values` initializer list if a value with an
808 /// equivalent key is not already contained in this map. This method
809 /// requires that the (template parameter) type `KEY` be copy-insertable
810 /// (see {Requirements on `KEY`, `HASH`, and `EQUAL`}).
811 void insert(bsl::initializer_list<value_type> values);
812#endif
813
814 /// Change the capacity of this map to at least the specified
815 /// `minimumCapacity`, and redistribute all the contained elements into
816 /// a new sequence of entries according to their hash values. If
817 /// `0 == minimumCapacity` and `0 == size()`, the map is returned to the
818 /// default constructed state. After this call, `load_factor()` will be
819 /// less than or equal to `max_load_factor()` and all iterators,
820 /// pointers, and references to elements of this map are invalidated.
821 void rehash(bsl::size_t minimumCapacity);
822
823 /// Change the capacity of this map to at least a capacity that can
824 /// accommodate the specified `numEntries` (accounting for the load
825 /// factor invariant), and redistribute all the contained elements into
826 /// a new sequence of entries according to their hash values. If
827 /// `0 == numEntries` and `0 == size()`, the map is returned to the
828 /// default constructed state. After this call, `load_factor()` will be
829 /// less than or equal to `max_load_factor()` and all iterators,
830 /// pointers, and references to elements of this map are invalidated.
831 /// Note that this method is effectively equivalent to:
832 /// @code
833 /// rehash(bsl::ceil(numEntries / max_load_factor()))
834 /// @endcode
835 void reserve(bsl::size_t numEntries);
836
837 /// Remove all elements from this map and release all memory from this
838 /// map, returning the map to the default constructed state.
839 void reset();
840
841#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
842#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_PAIR_PIECEWISE_CONSTRUCTOR
843 /// If a key equivalent to the specified `key` already exists in this
844 /// map, return a pair containing an iterator referring to the existing
845 /// item, and `false`. Otherwise, insert into this map a newly-created
846 /// `value_type` object, constructed from `key` and the specified
847 /// `args`, and return a pair containing an iterator referring to the
848 /// newly-created entry and `true`. This method requires that the
849 /// (template parameter) types `KEY` and `VALUE` are
850 /// `emplace-constructible` from `key` and `args` respectively. For
851 /// C++03, `VALUE` must also be `copy-constructible`.
852 template< class... ARGS>
853 bsl::pair<iterator, bool> try_emplace(const KEY& key, ARGS&&... args);
854
855 /// If a key equivalent to the specified `key` already exists in this
856 /// map, return a pair containing an iterator referring to the existing
857 /// item and `false`. Otherwise, insert into this map a newly-created
858 /// `value_type` object, constructed from `std::forward<KEY>(key)` and
859 /// the specified `args`, and return a pair containing an iterator
860 /// referring to the newly-created entry, and `true`. This method
861 /// requires that the (template parameter) types `KEY` and `VALUE` are
862 /// `emplace-constructible` from `key` and `args` respectively. For
863 /// C++03, `VALUE` must also be `copy-constructible`.
864 template <class... ARGS>
865 bsl::pair<iterator, bool> try_emplace(
866 BloombergLP::bslmf::MovableRef<KEY> key,
867 ARGS&&... args);
868
869 /// If a key equivalent to the specified `key` already exists in this
870 /// map, return an iterator referring to the existing item. Otherwise,
871 /// insert into this map a newly-created `value_type` object,
872 /// constructed from `key` and the specified `args`, and return an
873 /// iterator referring to the newly-created entry. This method requires
874 /// that the (template parameter) types `KEY` and `VALUE` are
875 /// `emplace-constructible` from `key` and `args` respectively. For
876 /// C++03, `VALUE` must also be `copy-constructible`.
877 template<class... ARGS>
879 try_emplace(const_iterator, const KEY& key, ARGS&&... args);
880
881 /// If a key equivalent to the specified `key` already exists in this
882 /// map, return an iterator referring to the existing item. Otherwise,
883 /// insert into this map a newly-created `value_type` object,
884 /// constructed from `std::forward<KEY>(key)` and the specified `args`,
885 /// and return an iterator referring to the newly-created entry. This
886 /// method requires that the (template parameter) types `KEY` and
887 /// `VALUE` are `emplace-constructible` from `key` and `args`
888 /// respectively. For C++03, `VALUE` must also be `copy-constructible`.
889 template <class... ARGS>
890 iterator try_emplace(const_iterator,
891 BloombergLP::bslmf::MovableRef<KEY> key,
892 ARGS&&... args);
893#endif
894#endif
895
896 // Iterators
897
898 /// Return an iterator to the first element in the sequence of
899 /// modifiable elements maintained by this map, or the `end` iterator if
900 /// this map is empty.
901 iterator begin();
902
903 /// Return an iterator to the past-the-end element in the sequence of
904 /// modifiable elements maintained by this map.
905 iterator end();
906
907 // Aspects
908
909 /// Exchange the value of this object as well as its hasher and equality
910 /// functors with those of the specified `other` object. The behavior
911 /// is undefined unless this object was created with the same allocator
912 /// as `other`.
913 void swap(FlatHashMap& other);
914
915 // ACCESSORS
916
917 /// Return a reference providing non-modifiable access to the mapped
918 /// value associated with the specified `key` in this map, if such an
919 /// entry exists; otherwise throw a `std::out_of_range` exception. Note
920 /// that this method is not exception-neutral.
921 const VALUE& at(const KEY& key) const;
922
923 /// Return the number of elements this map could hold if the load factor
924 /// were 1.
925 bsl::size_t capacity() const;
926
927 /// Return `true` if this map contains an element having the specified
928 /// `key`, and `false` otherwise.
929 bool contains(const KEY& key) const;
930
931 /// Return the number of elements in this map having the specified
932 /// `key`. Note that since a flat hash map maintains unique keys, the
933 /// returned value will be either 0 or 1.
934 bsl::size_t count(const KEY& key) const;
935
936 /// Return `true` if this map contains no elements, and `false`
937 /// otherwise.
938 bool empty() const;
939
940 /// Return a pair of `const_iterator`s defining the sequence of elements
941 /// in this map having the specified `key`, where the first iterator is
942 /// positioned at the start of the sequence and the second iterator is
943 /// positioned one past the end of the sequence. If this map contains
944 /// no elements having a key equivalent to `key`, then the two returned
945 /// iterators will have the same value. Note that since a map maintains
946 /// unique keys, the range will contain at most one element.
948 const KEY& key) const;
949
950 /// Return a `const_iterator` referring to the element in this map
951 /// having the specified `key`, or `end()` if no such entry exists in
952 /// this map.
953 const_iterator find(const KEY& key) const;
954
955 /// Return (a copy of) the unary hash functor used by this map to
956 /// generate a hash value (of type `bsl::size_t`) for a `KEY` object.
957 HASH hash_function() const;
958
959 /// Return (a copy of) the binary key-equality functor that returns
960 /// `true` if the value of two `KEY` objects are equivalent, and `false`
961 /// otherwise.
962 EQUAL key_eq() const;
963
964 /// Return the current ratio between the number of elements in this
965 /// container and its capacity.
966 float load_factor() const;
967
968 /// Return the maximum load factor allowed for this map. Note that if
969 /// an insert operation would cause the load factor to exceed
970 /// `max_load_factor()`, that same insert operation will increase the
971 /// capacity and rehash the entries of the container (see {Load Factor
972 /// and Resizing}). Also note that the value returned by
973 /// `max_load_factor` is implementation defined and cannot be changed by
974 /// the user.
975 float max_load_factor() const;
976
977 /// Return the number of elements in this map.
978 bsl::size_t size() const;
979
980 // Iterators
981
982 /// Return a `const_iterator` to the first element in the sequence of
983 /// elements maintained by this map, or the `end` iterator if this map
984 /// is empty.
985 const_iterator begin() const;
986
987 /// Return a `const_iterator` to the first element in the sequence of
988 /// elements maintained by this map, or the `end` iterator if this map
989 /// is empty.
990 const_iterator cbegin() const;
991
992 /// Return a `const_iterator` to the past-the-end element in the
993 /// sequence of elements maintained by this map.
994 const_iterator cend() const;
995
996 /// Return a `const_iterator` to the past-the-end element in the
997 /// sequence of elements maintained by this map.
998 const_iterator end() const;
999
1000 // Aspects
1001
1002 /// Return the allocator used by this flat hash map to supply memory.
1003 bslma::Allocator *allocator() const;
1004
1005 /// Format this object to the specified output `stream` at the (absolute
1006 /// value of) the optionally specified indentation `level`, and return a
1007 /// reference to the modifiable `stream`. If `level` is specified,
1008 /// optionally specify `spacesPerLevel`, the number of spaces per
1009 /// indentation level for this and all of its nested objects. If
1010 /// `level` is negative, suppress indentation of the first line. If
1011 /// `spacesPerLevel` is negative, format the entire output on one line,
1012 /// suppressing all but the initial indentation (as governed by
1013 /// `level`). If `stream` is not valid on entry, this operation has no
1014 /// effect.
1015 bsl::ostream& print(bsl::ostream& stream,
1016 int level = 0,
1017 int spacesPerLevel = 4) const;
1018};
1019
1020// FREE OPERATORS
1021
1022/// Return `true` if the specified `lhs` and `rhs` objects have the same
1023/// value, and `false` otherwise. Two `FlatHashMap` objects have the same
1024/// value if their sizes are the same and each element contained in one is
1025/// equal to an element of the other. The hash and equality functors are
1026/// not involved in the comparison.
1027template <class KEY, class VALUE, class HASH, class EQUAL>
1028bool operator==(const FlatHashMap<KEY, VALUE, HASH, EQUAL> &lhs,
1029 const FlatHashMap<KEY, VALUE, HASH, EQUAL> &rhs);
1030
1031/// Return `true` if the specified `lhs` and `rhs` objects do not have the
1032/// same value, and `false` otherwise. Two `FlatHashMap` objects do not
1033/// have the same value if their sizes are different or one contains an
1034/// element equal to no element of the other. The hash and equality
1035/// functors are not involved in the comparison.
1036template <class KEY, class VALUE, class HASH, class EQUAL>
1037bool operator!=(const FlatHashMap<KEY, VALUE, HASH, EQUAL> &lhs,
1038 const FlatHashMap<KEY, VALUE, HASH, EQUAL> &rhs);
1039
1040/// Write the value of the specified `map` to the specified output `stream`
1041/// in a single-line format, and return a reference providing modifiable
1042/// access to `stream`. If `stream` is not valid on entry, this operation
1043/// has no effect. Note that this human-readable format is not fully
1044/// specified and can change without notice.
1045template <class KEY, class VALUE, class HASH, class EQUAL>
1046bsl::ostream& operator<<(bsl::ostream& stream,
1048
1049// FREE FUNCTIONS
1050
1051/// Exchange the value, the hasher, and the key-equality functor of the
1052/// specified `a` and `b` objects. This function provides the no-throw
1053/// exception-safety guarantee if the two objects were created with the same
1054/// allocator and the basic guarantee otherwise.
1055template <class KEY, class VALUE, class HASH, class EQUAL>
1058
1059// ============================================================================
1060// TEMPLATE AND INLINE FUNCTION DEFINITIONS
1061// ============================================================================
1062
1063 // ----------------------------
1064 // struct FlatHashMap_EntryUtil
1065 // ----------------------------
1066
1067// CLASS METHODS
1068#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1069template <class KEY, class VALUE, class ENTRY>
1070template <class... ARGS>
1071inline
1073 ENTRY *entry,
1074 bslma::Allocator *allocator,
1075 ARGS&&... args)
1076{
1077 BSLS_ASSERT_SAFE(entry);
1079 entry,
1080 allocator,
1081 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
1082}
1083#endif
1084
1085template <class KEY, class VALUE, class ENTRY>
1086template <class KEY_TYPE>
1087inline
1089 ENTRY *entry,
1090 bslma::Allocator *allocator,
1092{
1093 BSLS_ASSERT_SAFE(entry);
1094
1096
1097 bslma::ConstructionUtil::construct(value.address(), allocator);
1099
1101 entry,
1102 allocator,
1103 BSLS_COMPILERFEATURES_FORWARD(KEY_TYPE, key),
1105}
1106
1107template <class KEY, class VALUE, class ENTRY>
1108inline
1110{
1111 return entry.first;
1112}
1113
1114 // -----------------
1115 // class FlatHashMap
1116 // -----------------
1117
1118// CREATORS
1119template <class KEY, class VALUE, class HASH, class EQUAL>
1120inline
1122: d_impl(0, HASH(), EQUAL())
1123{
1124}
1125
1126template <class KEY, class VALUE, class HASH, class EQUAL>
1127inline
1129 bslma::Allocator *basicAllocator)
1130: d_impl(0, HASH(), EQUAL(), basicAllocator)
1131{
1132}
1133
1134template <class KEY, class VALUE, class HASH, class EQUAL>
1135inline
1137: d_impl(capacity, HASH(), EQUAL())
1138{
1139}
1140
1141template <class KEY, class VALUE, class HASH, class EQUAL>
1142inline
1144 bsl::size_t capacity,
1145 bslma::Allocator *basicAllocator)
1146: d_impl(capacity, HASH(), EQUAL(), basicAllocator)
1147{
1148}
1149
1150template <class KEY, class VALUE, class HASH, class EQUAL>
1151inline
1153 bsl::size_t capacity,
1154 const HASH& hash,
1155 bslma::Allocator *basicAllocator)
1156: d_impl(capacity, hash, EQUAL(), basicAllocator)
1157{
1158}
1159
1160template <class KEY, class VALUE, class HASH, class EQUAL>
1161inline
1163 bsl::size_t capacity,
1164 const HASH& hash,
1165 const EQUAL& equal,
1166 bslma::Allocator *basicAllocator)
1167: d_impl(capacity, hash, equal, basicAllocator)
1168{
1169}
1170
1171template <class KEY, class VALUE, class HASH, class EQUAL>
1172template <class INPUT_ITERATOR>
1173inline
1175 INPUT_ITERATOR first,
1176 INPUT_ITERATOR last,
1177 bslma::Allocator *basicAllocator)
1178: d_impl(0, HASH(), EQUAL(), basicAllocator)
1179{
1180 insert(first, last);
1181}
1182
1183template <class KEY, class VALUE, class HASH, class EQUAL>
1184template <class INPUT_ITERATOR>
1185inline
1187 INPUT_ITERATOR first,
1188 INPUT_ITERATOR last,
1189 bsl::size_t capacity,
1190 bslma::Allocator *basicAllocator)
1191: d_impl(capacity, HASH(), EQUAL(), basicAllocator)
1192{
1193 insert(first, last);
1194}
1195
1196template <class KEY, class VALUE, class HASH, class EQUAL>
1197template <class INPUT_ITERATOR>
1198inline
1200 INPUT_ITERATOR first,
1201 INPUT_ITERATOR last,
1202 bsl::size_t capacity,
1203 const HASH& hash,
1204 bslma::Allocator *basicAllocator)
1205: d_impl(capacity, hash, EQUAL(), basicAllocator)
1206{
1207 insert(first, last);
1208}
1209
1210template <class KEY, class VALUE, class HASH, class EQUAL>
1211template <class INPUT_ITERATOR>
1212inline
1214 INPUT_ITERATOR first,
1215 INPUT_ITERATOR last,
1216 bsl::size_t capacity,
1217 const HASH& hash,
1218 const EQUAL& equal,
1219 bslma::Allocator *basicAllocator)
1220: d_impl(capacity, hash, equal, basicAllocator)
1221{
1222 insert(first, last);
1223}
1224
1225#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1226template <class KEY, class VALUE, class HASH, class EQUAL>
1227inline
1229 bsl::initializer_list<value_type> values,
1230 bslma::Allocator *basicAllocator)
1231: FlatHashMap(values.begin(),
1232 values.end(),
1233 0,
1234 HASH(),
1235 EQUAL(),
1236 basicAllocator)
1237{
1238}
1239
1240template <class KEY, class VALUE, class HASH, class EQUAL>
1241inline
1243 bsl::initializer_list<value_type> values,
1244 bsl::size_t capacity,
1245 bslma::Allocator *basicAllocator)
1246: FlatHashMap(values.begin(),
1247 values.end(),
1248 capacity,
1249 HASH(),
1250 EQUAL(),
1251 basicAllocator)
1252{
1253}
1254
1255template <class KEY, class VALUE, class HASH, class EQUAL>
1256inline
1258 bsl::initializer_list<value_type> values,
1259 bsl::size_t capacity,
1260 const HASH& hash,
1261 bslma::Allocator *basicAllocator)
1262: FlatHashMap(values.begin(),
1263 values.end(),
1264 capacity,
1265 hash,
1266 EQUAL(),
1267 basicAllocator)
1268{
1269}
1270
1271template <class KEY, class VALUE, class HASH, class EQUAL>
1272inline
1274 bsl::initializer_list<value_type> values,
1275 bsl::size_t capacity,
1276 const HASH& hash,
1277 const EQUAL& equal,
1278 bslma::Allocator *basicAllocator)
1279: FlatHashMap(values.begin(),
1280 values.end(),
1281 capacity,
1282 hash,
1283 equal,
1284 basicAllocator)
1285{
1286}
1287#endif
1288
1289template <class KEY, class VALUE, class HASH, class EQUAL>
1290inline
1292 const FlatHashMap& original,
1293 bslma::Allocator *basicAllocator)
1294: d_impl(original.d_impl, basicAllocator)
1295{
1296}
1297
1298template <class KEY, class VALUE, class HASH, class EQUAL>
1299inline
1302: d_impl(bslmf::MovableRefUtil::move(
1303 bslmf::MovableRefUtil::access(original).d_impl))
1304{
1305}
1306
1307template <class KEY, class VALUE, class HASH, class EQUAL>
1308inline
1311 bslma::Allocator *basicAllocator)
1312: d_impl(bslmf::MovableRefUtil::move(
1313 bslmf::MovableRefUtil::access(original).d_impl),
1314 basicAllocator)
1315{
1316}
1317
1318template <class KEY, class VALUE, class HASH, class EQUAL>
1319inline
1323
1324// MANIPULATORS
1325template <class KEY, class VALUE, class HASH, class EQUAL>
1326inline
1329{
1330 d_impl = rhs.d_impl;
1331
1332 return *this;
1333}
1334
1335template <class KEY, class VALUE, class HASH, class EQUAL>
1336inline
1340{
1341 FlatHashMap& lvalue = rhs;
1342
1343 d_impl = bslmf::MovableRefUtil::move(lvalue.d_impl);
1344
1345 return *this;
1346}
1347
1348#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1349template <class KEY, class VALUE, class HASH, class EQUAL>
1350inline
1353 bsl::initializer_list<value_type> values)
1354{
1355 FlatHashMap tmp(values.begin(),
1356 values.end(),
1357 0,
1358 d_impl.hash_function(),
1359 d_impl.key_eq(),
1360 d_impl.allocator());
1361
1362 this->swap(tmp);
1363
1364 return *this;
1365}
1366#endif
1367
1368template <class KEY, class VALUE, class HASH, class EQUAL>
1369template <class KEY_TYPE>
1370inline
1373{
1374 return d_impl[BSLS_COMPILERFEATURES_FORWARD(KEY_TYPE, key)].second;
1375}
1376
1377template <class KEY, class VALUE, class HASH, class EQUAL>
1378inline
1380{
1381 iterator node = d_impl.find(key);
1382
1383 if (node == d_impl.end()) {
1384 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
1385 "FlatHashMap<...>::at(key_type): invalid key value");
1386 }
1387
1388 return node->second;
1389}
1390
1391template <class KEY, class VALUE, class HASH, class EQUAL>
1392inline
1393void
1398
1399template <class KEY, class VALUE, class HASH, class EQUAL>
1403{
1404 return d_impl.equal_range(key);
1405}
1406
1407#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1408template <class KEY, class VALUE, class HASH, class EQUAL>
1409template <class... ARGS>
1410inline
1413{
1414 return d_impl.emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
1415}
1416
1417template <class KEY, class VALUE, class HASH, class EQUAL>
1418template <class... ARGS>
1419inline
1422 ARGS&&... args)
1423{
1424 return emplace(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...).first;
1425}
1426#endif
1427
1428
1429template <class KEY, class VALUE, class HASH, class EQUAL>
1431{
1432 return d_impl.erase(key);
1433}
1434
1435template <class KEY, class VALUE, class HASH, class EQUAL>
1436inline
1439{
1440 BSLS_ASSERT_SAFE(position != end());
1441
1442 return d_impl.erase(position);
1443}
1444
1445template <class KEY, class VALUE, class HASH, class EQUAL>
1446inline
1449{
1450 // Note that this overload is necessary to avoid ambiguity when the key is
1451 // an iterator.
1452
1453 BSLS_ASSERT_SAFE(position != end());
1454
1455 return d_impl.erase(position);
1456}
1457
1458template <class KEY, class VALUE, class HASH, class EQUAL>
1461 const_iterator last)
1462{
1463 return d_impl.erase(first, last);
1464}
1465
1466template <class KEY, class VALUE, class HASH, class EQUAL>
1467inline
1470{
1471 return d_impl.find(key);
1472}
1473
1474template <class KEY, class VALUE, class HASH, class EQUAL>
1475template <class INPUT_ITERATOR>
1477 INPUT_ITERATOR last)
1478{
1479 d_impl.insert(first, last);
1480}
1481
1482#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1483template <class KEY, class VALUE, class HASH, class EQUAL>
1485 bsl::initializer_list<value_type> values)
1486{
1487 insert(values.begin(), values.end());
1488}
1489#endif
1490
1491template <class KEY, class VALUE, class HASH, class EQUAL>
1492inline
1493void FlatHashMap<KEY, VALUE, HASH, EQUAL>::rehash(bsl::size_t minimumCapacity)
1494{
1495 d_impl.rehash(minimumCapacity);
1496}
1497
1498template <class KEY, class VALUE, class HASH, class EQUAL>
1499inline
1501{
1502 d_impl.reserve(numEntries);
1503}
1504
1505template <class KEY, class VALUE, class HASH, class EQUAL>
1506inline
1508{
1509 d_impl.reset();
1510}
1511
1512#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1513#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_PAIR_PIECEWISE_CONSTRUCTOR
1514template <class KEY, class VALUE, class HASH, class EQUAL>
1515template< class... ARGS>
1516inline
1519 ARGS&&... args)
1520{
1521 return d_impl.try_emplace(
1522 key,
1523 std::piecewise_construct,
1524 std::forward_as_tuple(key),
1525 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...));
1526}
1527
1528template <class KEY, class VALUE, class HASH, class EQUAL>
1529template <class... ARGS>
1531FlatHashMap<KEY, VALUE, HASH, EQUAL>::try_emplace(
1532 BloombergLP::bslmf::MovableRef<KEY> key,
1533 ARGS&&... args)
1534{
1535 return d_impl.try_emplace(
1537 std::piecewise_construct,
1538 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(KEY, key)),
1539 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...));
1540}
1541
1542template <class KEY, class VALUE, class HASH, class EQUAL>
1543template<class... ARGS>
1545FlatHashMap<KEY, VALUE, HASH, EQUAL>::try_emplace(const_iterator,
1546 const KEY& key,
1547 ARGS&&... args)
1548{
1549 return d_impl.try_emplace(
1550 key,
1551 std::piecewise_construct,
1552 std::forward_as_tuple(key),
1553 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...))
1554 .first;
1555}
1556
1557template <class KEY, class VALUE, class HASH, class EQUAL>
1558template <class... ARGS>
1560FlatHashMap<KEY, VALUE, HASH, EQUAL>::try_emplace(const_iterator,
1561 BloombergLP::bslmf::MovableRef<KEY> key,
1562 ARGS&&... args)
1563{
1564 return d_impl.try_emplace(
1566 std::piecewise_construct,
1567 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(KEY, key)),
1568 std::forward_as_tuple(BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...))
1569 .first;
1570}
1571#endif
1572#endif
1573
1574 // Iterators
1575
1576template <class KEY, class VALUE, class HASH, class EQUAL>
1577inline
1580{
1581 return d_impl.begin();
1582}
1583
1584template <class KEY, class VALUE, class HASH, class EQUAL>
1585inline
1588{
1589 return d_impl.end();
1590}
1591
1592 // Aspects
1593
1594template <class KEY, class VALUE, class HASH, class EQUAL>
1595inline
1597{
1598 BSLS_ASSERT_SAFE(allocator() == other.allocator());
1599
1600 d_impl.swap(other.d_impl);
1601}
1602
1603// ACCESSORS
1604template <class KEY, class VALUE, class HASH, class EQUAL>
1605inline
1606const VALUE& FlatHashMap<KEY, VALUE, HASH, EQUAL>::at(const KEY& key) const
1607{
1608 const_iterator node = d_impl.find(key);
1609
1610 if (node == d_impl.end()) {
1611 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
1612 "FlatHashMap<...>::at(key_type) const: invalid key value");
1613 }
1614
1615 return node->second;
1616}
1617
1618template <class KEY, class VALUE, class HASH, class EQUAL>
1619inline
1621{
1622 return d_impl.capacity();
1623}
1624
1625template <class KEY, class VALUE, class HASH, class EQUAL>
1626inline
1628{
1629 return d_impl.contains(key);
1630}
1631
1632template <class KEY, class VALUE, class HASH, class EQUAL>
1633inline
1634bsl::size_t FlatHashMap<KEY, VALUE, HASH, EQUAL>::count(const KEY& key) const
1635{
1636 return d_impl.count(key);
1637}
1638
1639template <class KEY, class VALUE, class HASH, class EQUAL>
1640inline
1642{
1643 return d_impl.empty();
1644}
1645
1646template <class KEY, class VALUE, class HASH, class EQUAL>
1650{
1651 return d_impl.equal_range(key);
1652}
1653
1654template <class KEY, class VALUE, class HASH, class EQUAL>
1655inline
1658{
1659 return d_impl.find(key);
1660}
1661
1662template <class KEY, class VALUE, class HASH, class EQUAL>
1663inline
1665{
1666 return d_impl.hash_function();
1667}
1668
1669template <class KEY, class VALUE, class HASH, class EQUAL>
1670inline
1672{
1673 return d_impl.key_eq();
1674}
1675
1676template <class KEY, class VALUE, class HASH, class EQUAL>
1677inline
1679{
1680 return d_impl.load_factor();
1681}
1682
1683template <class KEY, class VALUE, class HASH, class EQUAL>
1684inline
1686{
1687 return d_impl.max_load_factor();
1688}
1689
1690template <class KEY, class VALUE, class HASH, class EQUAL>
1691inline
1693{
1694 return d_impl.size();
1695}
1696
1697 // Iterators
1698
1699template <class KEY, class VALUE, class HASH, class EQUAL>
1700inline
1703{
1704 return d_impl.begin();
1705}
1706template <class KEY, class VALUE, class HASH, class EQUAL>
1707inline
1710{
1711 return d_impl.cbegin();
1712}
1713
1714template <class KEY, class VALUE, class HASH, class EQUAL>
1715inline
1718{
1719 return d_impl.cend();
1720}
1721
1722template <class KEY, class VALUE, class HASH, class EQUAL>
1723inline
1726{
1727 return d_impl.end();
1728}
1729
1730 // Aspects
1731
1732template <class KEY, class VALUE, class HASH, class EQUAL>
1733inline
1738
1739template <class KEY, class VALUE, class HASH, class EQUAL>
1741 bsl::ostream& stream,
1742 int level,
1743 int spacesPerLevel) const
1744{
1745 if (stream.bad()) {
1746 return stream; // RETURN
1747 }
1748
1749 bslim::Printer printer(&stream, level, spacesPerLevel);
1750
1751 printer.start();
1752
1753 const_iterator iter = begin();
1754 while (iter != end()) {
1755 printer.printValue(*iter);
1756 ++iter;
1757 }
1758
1759 printer.end();
1760
1761 return stream;
1762}
1763
1764} // close package namespace
1765
1766// FREE OPERATORS
1767template <class KEY, class VALUE, class HASH, class EQUAL>
1768inline
1769bool bdlc::operator==(const FlatHashMap<KEY, VALUE, HASH, EQUAL>& lhs,
1770 const FlatHashMap<KEY, VALUE, HASH, EQUAL>& rhs)
1771{
1772 return lhs.d_impl == rhs.d_impl;
1773}
1774
1775template <class KEY, class VALUE, class HASH, class EQUAL>
1776inline
1777bool bdlc::operator!=(const FlatHashMap<KEY, VALUE, HASH, EQUAL>& lhs,
1778 const FlatHashMap<KEY, VALUE, HASH, EQUAL>& rhs)
1779{
1780 return lhs.d_impl != rhs.d_impl;
1781}
1782
1783template <class KEY, class VALUE, class HASH, class EQUAL>
1784inline
1785bsl::ostream& bdlc::operator<<(
1786 bsl::ostream& stream,
1787 const FlatHashMap<KEY, VALUE, HASH, EQUAL>& map)
1788{
1789 return map.print(stream, 0, -1);
1790}
1791
1792// FREE FUNCTIONS
1793template <class KEY, class VALUE, class HASH, class EQUAL>
1794inline
1795void bdlc::swap(FlatHashMap<KEY, VALUE, HASH, EQUAL>& a,
1796 FlatHashMap<KEY, VALUE, HASH, EQUAL>& b)
1797{
1798 bslalg::SwapUtil::swap(&a.d_impl, &b.d_impl);
1799}
1800
1801// ============================================================================
1802// TYPE TRAITS
1803// ============================================================================
1804
1805namespace bslalg {
1806
1807template <class KEY, class VALUE, class HASH, class EQUAL>
1808struct HasStlIterators<bdlc::FlatHashMap<KEY, VALUE, HASH, EQUAL> >
1810};
1811
1812} // close namespace bslalg
1813
1814namespace bslma {
1815
1816template <class KEY, class VALUE, class HASH, class EQUAL>
1817struct UsesBslmaAllocator<bdlc::FlatHashMap<KEY, VALUE, HASH, EQUAL> >
1819};
1820
1821} // close namespace bslma
1822
1823
1824#endif // End C++11 code
1825
1826#endif
1827
1828// ----------------------------------------------------------------------------
1829// Copyright 2020 Bloomberg Finance L.P.
1830//
1831// Licensed under the Apache License, Version 2.0 (the "License");
1832// you may not use this file except in compliance with the License.
1833// You may obtain a copy of the License at
1834//
1835// http://www.apache.org/licenses/LICENSE-2.0
1836//
1837// Unless required by applicable law or agreed to in writing, software
1838// distributed under the License is distributed on an "AS IS" BASIS,
1839// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1840// See the License for the specific language governing permissions and
1841// limitations under the License.
1842// ----------------------------- END-OF-FILE ----------------------------------
1843
1844/** @} */
1845/** @} */
1846/** @} */
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlc_flathashmap.h:433
HASH hasher
Definition bdlc_flathashmap.h:464
const value_type * const_pointer
Definition bdlc_flathashmap.h:468
value_type * pointer
Definition bdlc_flathashmap.h:467
bsl::ptrdiff_t difference_type
Definition bdlc_flathashmap.h:462
friend void swap(FlatHashMap< K, V, H, E > &, FlatHashMap< K, V, H, E > &)
const value_type & const_reference
Definition bdlc_flathashmap.h:466
void clear()
Definition bdlc_flathashmap.h:1394
VALUE & at(const KEY &key)
Definition bdlc_flathashmap.h:1379
EQUAL key_eq() const
Definition bdlc_flathashmap.h:1671
iterator find(const KEY &key)
Definition bdlc_flathashmap.h:1469
bool contains(const KEY &key) const
Definition bdlc_flathashmap.h:1627
ImplType::const_iterator const_iterator
Definition bdlc_flathashmap.h:470
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, iterator >::type insert(const_iterator, BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE) value)
Definition bdlc_flathashmap.h:785
bool empty() const
Definition bdlc_flathashmap.h:1641
const_iterator cbegin() const
Definition bdlc_flathashmap.h:1709
bsl::size_t size() const
Return the number of elements in this map.
Definition bdlc_flathashmap.h:1692
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, bsl::pair< iterator, bool > >::type insert(BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE) value)
Definition bdlc_flathashmap.h:758
void rehash(bsl::size_t minimumCapacity)
Definition bdlc_flathashmap.h:1493
bslma::Allocator * allocator() const
Return the allocator used by this flat hash map to supply memory.
Definition bdlc_flathashmap.h:1734
bsl::pair< iterator, bool > emplace(ARGS &&... args)
bsl::pair< iterator, iterator > equal_range(const KEY &key)
Definition bdlc_flathashmap.h:1402
VALUE & operator[](BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) key)
Definition bdlc_flathashmap.h:1371
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlc_flathashmap.h:1740
const_iterator cend() const
Definition bdlc_flathashmap.h:1717
void reserve(bsl::size_t numEntries)
Definition bdlc_flathashmap.h:1500
float load_factor() const
Definition bdlc_flathashmap.h:1678
HASH hash_function() const
Definition bdlc_flathashmap.h:1664
~FlatHashMap()
Destroy this object and each of its elements.
Definition bdlc_flathashmap.h:1320
bsl::size_t erase(const KEY &key)
Definition bdlc_flathashmap.h:1430
iterator begin()
Definition bdlc_flathashmap.h:1579
FlatHashMap & operator=(const FlatHashMap &rhs)
Definition bdlc_flathashmap.h:1328
EQUAL key_compare
Definition bdlc_flathashmap.h:463
KEY key_type
Definition bdlc_flathashmap.h:459
FlatHashMap()
Definition bdlc_flathashmap.h:1121
ImplType::iterator iterator
Definition bdlc_flathashmap.h:469
float max_load_factor() const
Definition bdlc_flathashmap.h:1685
value_type & reference
Definition bdlc_flathashmap.h:465
void reset()
Definition bdlc_flathashmap.h:1507
bsl::size_t capacity() const
Definition bdlc_flathashmap.h:1620
iterator emplace_hint(const_iterator hint, ARGS &&... args)
Definition bdlc_flathashmap.h:1421
bsl::size_t count(const KEY &key) const
Definition bdlc_flathashmap.h:1634
VALUE mapped_type
Definition bdlc_flathashmap.h:460
bsl::pair< typename bsl::add_const< KEY >::type, VALUE > value_type
Definition bdlc_flathashmap.h:457
iterator end()
Definition bdlc_flathashmap.h:1587
bsl::size_t size_type
Definition bdlc_flathashmap.h:461
Definition bdlc_flathashtable.h:317
void clear()
Definition bdlc_flathashtable.h:1580
bsl::size_t erase(const KEY &key)
Definition bdlc_flathashtable.h:1632
float max_load_factor() const
Definition bdlc_flathashtable.h:2056
const_iterator cbegin() const
Definition bdlc_flathashtable.h:2092
void swap(FlatHashTable &other)
Definition bdlc_flathashtable.h:1918
void reset()
Definition bdlc_flathashtable.h:1806
bsl::pair< iterator, bool > emplace(ARGS &&... args)
iterator find(const KEY &key)
Definition bdlc_flathashtable.h:1741
iterator end()
Definition bdlc_flathashtable.h:1909
bool empty() const
Definition bdlc_flathashtable.h:1970
bsl::pair< iterator, bool > try_emplace(const KEY &key, ARGS &&... args)
bsl::enable_if< bsl::is_convertible< ENTRY_TYPE, ENTRY >::value, bsl::pair< iterator, bool > >::type insert(BSLS_COMPILERFEATURES_FORWARD_REF(ENTRY_TYPE) entry)
Definition bdlc_flathashtable.h:564
bslma::Allocator * allocator() const
Return the allocator used by this hash table to supply memory.
Definition bdlc_flathashtable.h:2118
bsl::size_t capacity() const
Definition bdlc_flathashtable.h:1936
bslstl::ForwardIterator< const bsl::pair< KEY, VALUE >, IteratorImp > const_iterator
Definition bdlc_flathashtable.h:334
bslstl::ForwardIterator< bsl::pair< KEY, VALUE >, IteratorImp > iterator
Definition bdlc_flathashtable.h:332
EQUAL key_eq() const
Definition bdlc_flathashtable.h:2032
bool contains(const KEY &key) const
Definition bdlc_flathashtable.h:1943
iterator begin()
Definition bdlc_flathashtable.h:1892
void reserve(bsl::size_t numEntries)
Definition bdlc_flathashtable.h:1787
const_iterator cend() const
Definition bdlc_flathashtable.h:2100
bsl::size_t size() const
Return the number of entries in this table.
Definition bdlc_flathashtable.h:2064
bsl::size_t count(const KEY &key) const
Definition bdlc_flathashtable.h:1962
HASH hash_function() const
Definition bdlc_flathashtable.h:2025
float load_factor() const
Definition bdlc_flathashtable.h:2043
void rehash(bsl::size_t minimumCapacity)
Definition bdlc_flathashtable.h:1766
bsl::pair< iterator, iterator > equal_range(const KEY &key)
Definition bdlc_flathashtable.h:1599
Definition bslstl_pair.h:1210
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:194
Definition bslh_fibonaccibadhashwrapper.h:165
Definition bslim_printer.h:601
void printValue(const TYPE &data) const
Definition bslim_printer.h:1207
void end(bool suppressBracket=false) const
void start(bool suppressBracket=false) const
Definition bslma_allocator.h:457
Definition bslma_destructorguard.h:132
Definition bslmf_movableref.h:751
#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_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_bitarray.h:503
void swap(BitArray &a, BitArray &b)
bool operator==(const BitArray &lhs, const BitArray &rhs)
bool operator!=(const BitArray &lhs, const BitArray &rhs)
BitArray operator<<(const BitArray &array, bsl::size_t numBits)
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdlc_flathashmap.h:390
static void constructFromKey(ENTRY *entry, bslma::Allocator *allocator, BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) key)
Definition bdlc_flathashmap.h:1088
static const KEY & key(const ENTRY &entry)
Return the key of the specified entry.
Definition bdlc_flathashmap.h:1109
static void construct(ENTRY *entry, bslma::Allocator *allocator, ARGS &&... args)
Definition bdlc_flathashmap.h:1072
Definition bslmf_enableif.h:525
Definition bslstl_equalto.h:311
Definition bslalg_hasstliterators.h:99
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
Definition bslma_usesbslmaallocator.h:343
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
Definition bsls_objectbuffer.h:276
TYPE * address()
Definition bsls_objectbuffer.h:334
TYPE & object()
Definition bsls_objectbuffer.h:351