[#bsl-multiset-03]
= xref:bsl.adoc[bsl]::multiset
:relfileprefix: ../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an ordered sequence of possibly duplicate keys (of the template parameter type, `KEY`)&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;multiset&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class COMPARATOR = std::less&lt;KEY&gt;,
    class ALLOCATOR = xref:bsl/allocator-0df.adoc[bsl::allocator&lt;KEY&gt;]&gt;
class multiset;
----

== Description

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations

* except for BDEX serialization &ast; is _exception&hyphen;neutral_ (agnostic except for the `at` method) &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see &lcub;`bsldoc&lowbar;glossary`&rcub;&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multiset-03/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/multiset-03/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias to `iterator`&period;
| xref:bsl/multiset-03/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to the allocator const&hyphen;pointer type&period;
| xref:bsl/multiset-03/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias for `const&lowbar;reference`&period;
| xref:bsl/multiset-03/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| This `typedef` is an alias to the const reverse iterator type&period;
| xref:bsl/multiset-03/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to the allocator difference type&period;
| xref:bsl/multiset-03/iterator.adoc[`iterator`] 
| This `typedef` is an alias to the red&hyphen;black tree iterator type&period;
| xref:bsl/multiset-03/key_compare.adoc[`key&lowbar;compare`] 
| This `typedef` is an alias to the (template parameter) `COMPARATOR`&period;
| xref:bsl/multiset-03/key_type.adoc[`key&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `KEY` type&period;
| xref:bsl/multiset-03/pointer.adoc[`pointer`] 
| This `typedef` is an alias to the allocator pointer type&period;
| xref:bsl/multiset-03/reference.adoc[`reference`] 
| This `typedef` is an alias to `value&lowbar;type&amp;`&period;
| xref:bsl/multiset-03/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| This `typedef` is an alias to the reverse iterator type&period;
| xref:bsl/multiset-03/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to the allocator size type&period;
| xref:bsl/multiset-03/value_compare.adoc[`value&lowbar;compare`] 
| This `typedef` is an alias to `key&lowbar;compare`&period;
| xref:bsl/multiset-03/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `key&lowbar;type`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multiset-03/2constructor-05.adoc[`multiset`]         [.small]#[constructor]#
| Constructors
| xref:bsl/multiset-03/2destructor.adoc[`&#126;multiset`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/multiset-03/operator_assign-09.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/multiset-03/begin-00.adoc[`begin`] 
| `begin` overloads
| xref:bsl/multiset-03/cbegin.adoc[`cbegin`] 
| Return an iterator providing non&hyphen;modifiable access to the first `value&lowbar;type` object in the ordered sequence of `value&lowbar;type` objects maintained by this multiset, or the `end` iterator if this multiset is empty&period;
| xref:bsl/multiset-03/cend.adoc[`cend`] 
| Return an iterator providing non&hyphen;modifiable access to the past&hyphen;the&hyphen;end element in the ordered sequence of `value&lowbar;type` objects maintained by this multiset&period;
| xref:bsl/multiset-03/clear.adoc[`clear`] 
| Remove all entries from this multiset&period; Note that the multiset is empty after this call, but allocated memory may be retained for future use&period;
| xref:bsl/multiset-03/contains-0b.adoc[`contains`] 
| Return `true` if this map contains an element whose key is equivalent to the specified `key`&period;
| xref:bsl/multiset-03/count-064.adoc[`count`] 
| Return the number of `value&lowbar;type` objects within this multiset that are equivalent to the specified `key`&period;
| xref:bsl/multiset-03/crbegin.adoc[`crbegin`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the last `value&lowbar;type` object in the ordered sequence of `value&lowbar;type` objects maintained by this multiset, or `rend` if this multiset is empty&period;
| xref:bsl/multiset-03/crend.adoc[`crend`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the prior&hyphen;to&hyphen;the&hyphen;beginning element in the ordered sequence of `value&lowbar;type` objects maintained by this multiset&period;
| xref:bsl/multiset-03/emplace.adoc[`emplace`] 
| Insert into this multiset a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type`&period; Return an iterator referring to the newly created and inserted object in this multiset&period; This method requires that the (template parameter) type `KEY` be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `KEY`&rcub;)&period;
| xref:bsl/multiset-03/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Insert into this multiset a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type` (in amortized constant time if the specified `hint` is a valid immediate successor to the `value&lowbar;type` object constructed from `args`)&period; Return an iterator referring to the newly created and inserted object in this multiset&period; If `hint` is not a valid immediate successor to the `value&lowbar;type` object implied by `args`, this operation has `O&lsqb;log(N)&rsqb;` complexity where `N` is the size of this multiset&period; This method requires that the (template parameter) type `KEY` be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `KEY`&rcub;)&period; The behavior is undefined unless `hint` is an iterator in the range `&lsqb;begin() &period;&period; end()&rsqb;` (both endpoints included)&period;
| xref:bsl/multiset-03/empty.adoc[`empty`] 
| Return `true` if this multiset contains no elements, and `false` otherwise&period;
| xref:bsl/multiset-03/end-05.adoc[`end`] 
| `end` overloads
| xref:bsl/multiset-03/equal_range-00.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:bsl/multiset-03/erase-0f.adoc[`erase`] 
| `erase` overloads
| xref:bsl/multiset-03/find-0b.adoc[`find`] 
| `find` overloads
| xref:bsl/multiset-03/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this multiset&period;
| xref:bsl/multiset-03/insert-07.adoc[`insert`] 
| `insert` overloads
| xref:bsl/multiset-03/insert_range.adoc[`insert&lowbar;range`] 
| Insert into this multiset the value of each `value&lowbar;type` object in the specified `range` if the key equivalent of that object is not already contained in this map&period; The (template parameter) type `RANGE` must meet the requirements the C&plus;&plus;20 standard &lsqb;ranges&rsqb;providing access to values of a type convertible to `value&lowbar;type`, and `value&lowbar;type` must be `emplace&hyphen;constructible` from `&ast;i` into this map, where `i` is a dereferenceable iterator obtained from `range` (see &lcub;Requirements on `KEY`&rcub;)&period; The behavior is undefined if `range` overlaps this multiset&period;
| xref:bsl/multiset-03/key_comp.adoc[`key&lowbar;comp`] 
| Return the key&hyphen;comparison functor (or function pointer) used by this multiset&semi; if a comparator was supplied at construction, return its value, otherwise return a default constructed `key&lowbar;compare` object&period; Note that this comparator compares objects of type `KEY`, which is the type of the `value&lowbar;type` objects contained in this multiset&period;
| xref:bsl/multiset-03/lower_bound-04.adoc[`lower&lowbar;bound`] 
| `lower&lowbar;bound` overloads
| xref:bsl/multiset-03/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on the largest number of elements that this multiset could possibly hold&period; Note that there is no guarantee that the multiset can successfully grow to the returned size, or even close to that size without running out of resources&period;
| xref:bsl/multiset-03/rbegin-01.adoc[`rbegin`] 
| `rbegin` overloads
| xref:bsl/multiset-03/rend-0f.adoc[`rend`] 
| `rend` overloads
| xref:bsl/multiset-03/size.adoc[`size`] 
| Return the number of elements in this multiset&period;
| xref:bsl/multiset-03/swap.adoc[`swap`] 
| Exchange the value and comparator of this object with those of the specified `other` object&semi; also exchange the allocator of this object with that of `other` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either this object was created with the same allocator as `other` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in this object and `other`, respectively&period; Note that this method&apos;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;
| xref:bsl/multiset-03/upper_bound-0e.adoc[`upper&lowbar;bound`] 
| `upper&lowbar;bound` overloads
| xref:bsl/multiset-03/value_comp.adoc[`value&lowbar;comp`] 
| Return a functor for comparing two `value&lowbar;type` objects using `key&lowbar;comp()`&period; Note that since `value&lowbar;type` is an alias to `KEY` for `multiset`, this method returns the same functor as `key&lowbar;comp()`&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multiset-02.adoc[`multiset&lt;KEY&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multiset`&period; This deduction guide does not participate unless the specified `ALLOC` is convertible to `bsl&colon;&colon;allocator&lt;KEY&gt;`&period;
| xref:bsl/multiset-06a.adoc[`multiset&lt;KEY&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the iterators supplied to the constructor of `multiset`&period; This deduction guide does not participate unless the specified `ALLOC` is convertible to `bsl&colon;&colon;allocator&lt;KEY&gt;`&period;
| xref:bsl/multiset-005.adoc[`multiset&lt;KEY, COMPARATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multiset`&period; Deduce the template parameter `COMPARATOR` from the other parameter passed to the constructor&period; This deduction guide does not participate unless the specified `ALLOC` is convertible to `bsl&colon;&colon;allocator&lt;KEY&gt;`&period;
| xref:bsl/multiset-0a.adoc[`multiset&lt;KEY, COMPARATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the iterators supplied to the constructor of `multiset`&period; Deduce the template parameter `COMPARATOR` from the other parameter passed to the constructor&period; This deduction guide does not participate unless the specified `ALLOC` is convertible to `bsl&colon;&colon;allocator&lt;KEY&gt;`&period;
| xref:bsl/multiset-05.adoc[`multiset&lt;KEY, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multiset`&period; Deduce the template parameters `COMPARATOR` and `ALLOCATOR` from the other parameters passed to the constructor&period;
| xref:bsl/multiset-060.adoc[`multiset&lt;KEY, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the iterators supplied to the constructor of `multiset`&period; Deduce the template parameters `COMPARATOR` and `ALLOCATOR` from the other parameters passed to the constructor&period; This guide does not participate unless the supplied (or defaulted) `ALLOCATOR` meets the requirements of a standard allocator&period;
| xref:bsl/multiset-00e.adoc[`multiset&lt;KEY, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multiset`&period; Deduce the template parameter `ALLOCATOR` from the other parameter passed to the constructor&period;
| xref:bsl/multiset-0f.adoc[`multiset&lt;KEY, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce the template parameter `KEY` from the `value&lowbar;type` of the iterators supplied to the constructor of `multiset`&period; Deduce the template parameter `ALLOCATOR` from the other parameter passed to the constructor&period; This deduction guide does not participate unless the supplied allocator meets the requirements of a standard allocator&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/erase_if-030.adoc[`erase&lowbar;if`]
| Erase all the elements in the specified multiset `ms` that satisfy the specified predicate `predicate`&period; Return the number of elements erased&period;
| xref:bsl/operator_3way-0ff.adoc[`operator&lt;&equals;&gt;`]
| Perform a lexicographic three&hyphen;way comparison of the specified `lhs` and the specified `rhs` multisets by using the comparison operators of `KEY` on each element&semi; return the result of that comparison&period;
| xref:bsl/operator_eq-0a8.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `multiset` objects `lhs` and `rhs` have the same value if they have the same number of keys, and each element in the ordered sequence of keys of `lhs` has the same value as the corresponding element in the ordered sequence of keys of `rhs`&period; This method requires that the (template parameter) type `KEY` be `equality&hyphen;comparable` (see &lcub;Requirements on `KEY`&rcub;)&period;
| xref:bsl/swap-001.adoc[`swap`]
| Exchange the values of the specified `a` and `b` multisets&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
