11#ifndef INCLUDED_BSLSTL_MULTISET_CPP03
12#define INCLUDED_BSLSTL_MULTISET_CPP03
63#ifdef COMPILING_BSLSTL_MULTISET_H
85 class COMPARATOR = std::less<KEY>,
93 typedef const KEY ValueType;
97 typedef BloombergLP::bslstl::SetComparator<KEY, COMPARATOR> Comparator;
101 typedef BloombergLP::bslstl::TreeNode<KEY> Node;
105 typedef BloombergLP::bslstl::TreeNodePool<KEY, ALLOCATOR> NodeFactory;
113 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
124 class DataWrapper :
public Comparator {
131 DataWrapper(
const DataWrapper&);
132 DataWrapper& operator=(
const DataWrapper&);
140 explicit DataWrapper(
const COMPARATOR& comparator,
141 const ALLOCATOR& basicAllocator);
148 DataWrapper(BloombergLP::bslmf::MovableRef<DataWrapper> original);
154 NodeFactory& nodeFactory();
160 const NodeFactory& nodeFactory()
const;
164 DataWrapper d_compAndAlloc;
168 BloombergLP::bslalg::RbTreeAnchor d_tree;
186 typedef BloombergLP::bslstl::TreeIterator<
const value_type,
189 typedef BloombergLP::bslstl::TreeIterator<
const value_type,
200 Comparator& comparator();
204 NodeFactory& nodeFactory();
211 void quickSwapExchangeAllocators(
multiset& other);
219 void quickSwapRetainAllocators(
multiset& other);
225 const Comparator& comparator()
const;
229 const NodeFactory& nodeFactory()
const;
246 explicit multiset(
const COMPARATOR& comparator,
247 const ALLOCATOR& basicAllocator = ALLOCATOR())
248 : d_compAndAlloc(comparator, basicAllocator)
264 explicit multiset(
const ALLOCATOR& basicAllocator);
283 multiset(BloombergLP::bslmf::MovableRef<multiset> original);
308 multiset(BloombergLP::bslmf::MovableRef<multiset> original,
336 template <
class INPUT_ITERATOR>
339 const COMPARATOR& comparator = COMPARATOR(),
340 const ALLOCATOR& basicAllocator = ALLOCATOR());
341 template <
class INPUT_ITERATOR>
344 const ALLOCATOR& basicAllocator);
346#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
347 multiset(std::initializer_list<KEY> values,
348 const COMPARATOR& comparator = COMPARATOR(),
349 const ALLOCATOR& basicAllocator = ALLOCATOR());
368 multiset(std::initializer_list<KEY> values,
369 const ALLOCATOR& basicAllocator);
389 AllocatorTraits::is_always_equal::value
390 && std::is_nothrow_move_assignable<COMPARATOR>::value);
405#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
491 template <class INPUT_ITERATOR>
492 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
494#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
499 void insert(std::initializer_list<KEY> values);
502#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
505#ifndef BSLSTL_MULTISET_VARIADIC_LIMIT
506#define BSLSTL_MULTISET_VARIADIC_LIMIT 10
508#ifndef BSLSTL_MULTISET_VARIADIC_LIMIT_A
509#define BSLSTL_MULTISET_VARIADIC_LIMIT_A BSLSTL_MULTISET_VARIADIC_LIMIT
511#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 0
515#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 1
516 template <
class Args_01>
520#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 2
521 template <
class Args_01,
527#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 3
528 template <
class Args_01,
536#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 4
537 template <
class Args_01,
547#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 5
548 template <
class Args_01,
560#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 6
561 template <
class Args_01,
575#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 7
576 template <
class Args_01,
592#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 8
593 template <
class Args_01,
611#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 9
612 template <
class Args_01,
632#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 10
633 template <
class Args_01,
656#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 0
660#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 1
661 template <
class Args_01>
666#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 2
667 template <
class Args_01,
674#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 3
675 template <
class Args_01,
684#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 4
685 template <
class Args_01,
696#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 5
697 template <
class Args_01,
710#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 6
711 template <
class Args_01,
726#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 7
727 template <
class Args_01,
744#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 8
745 template <
class Args_01,
764#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 9
765 template <
class Args_01,
786#if BSLSTL_MULTISET_VARIADIC_LIMIT_A >= 10
787 template <
class Args_01,
813 template <
class... Args>
816 template <
class... Args>
852 AllocatorTraits::is_always_equal::value
853 && bsl::is_nothrow_swappable<COMPARATOR>::value);
889 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
890 d_tree, this->comparator(), key));
899 template <
class LOOKUP_KEY>
901 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
904 find(
const LOOKUP_KEY& key)
906 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
907 d_tree, this->comparator(), key));
922 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
923 d_tree, this->comparator(), key));
936 template <
class LOOKUP_KEY>
938 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
943 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
944 d_tree, this->comparator(), key));
959 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
960 d_tree, this->comparator(), key));
973 template <
class LOOKUP_KEY>
975 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
980 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
981 d_tree, this->comparator(), key));
999 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1002 return pair<iterator, iterator>(startIt, endIt);
1015 template <
class LOOKUP_KEY>
1017 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1019 pair<iterator, iterator> >::type
1024 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1027 return pair<iterator, iterator>(startIt, endIt);
1090 template <class LOOKUP_KEY>
1091 typename
bsl::enable_if<
1092 BloombergLP::
bslmf::IsTransparentPredicate<COMPARATOR,
1095 contains(const LOOKUP_KEY& key)
const
1138 d_tree, this->comparator(), key));
1147 template <
class LOOKUP_KEY>
1149 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1152 find(
const LOOKUP_KEY& key)
const
1155 d_tree, this->comparator(), key));
1167 while (it !=
end() && !comparator()(key, *it.node())) {
1178 template <
class LOOKUP_KEY>
1180 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1183 count(
const LOOKUP_KEY& key)
const
1188 while (it !=
end() && !comparator()(key, *it.node())) {
1207 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1208 d_tree, this->comparator(), key));
1221 template <
class LOOKUP_KEY>
1223 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1228 return const_iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1229 d_tree, this->comparator(), key));
1244 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1245 d_tree, this->comparator(), key));
1258 template <
class LOOKUP_KEY>
1260 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1265 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1266 d_tree, this->comparator(), key));
1285 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1288 return pair<const_iterator, const_iterator>(startIt, endIt);
1302 template <
class LOOKUP_KEY>
1304 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1306 pair<const_iterator, const_iterator> >::type
1311 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1314 return pair<const_iterator, const_iterator>(startIt, endIt);
1320#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1330 class INPUT_ITERATOR,
1332 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1333 class COMPARATOR = std::less<KEY>,
1335 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1336 class = bsl::enable_if_t<
bsl::IsStdAllocator_v<ALLOCATOR>>
1338multiset(INPUT_ITERATOR,
1340 COMPARATOR = COMPARATOR(),
1341 ALLOCATOR = ALLOCATOR())
1342-> multiset<KEY, COMPARATOR, ALLOCATOR>;
1350 class INPUT_ITERATOR,
1354 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1355 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1356 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1358multiset(INPUT_ITERATOR, INPUT_ITERATOR, COMPARATOR, ALLOC *)
1359-> multiset<KEY, COMPARATOR>;
1367 class INPUT_ITERATOR,
1370 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1371 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1373multiset(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR)
1374-> multiset<KEY, std::less<KEY>, ALLOCATOR>;
1381 class INPUT_ITERATOR,
1384 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1385 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1386 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1388multiset(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1397 class COMPARATOR = std::less<KEY>,
1398 class ALLOCATOR = bsl::allocator<KEY>,
1399 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1400 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1402multiset(std::initializer_list<KEY>,
1403 COMPARATOR = COMPARATOR(),
1404 ALLOCATOR = ALLOCATOR())
1405-> multiset<KEY, COMPARATOR, ALLOCATOR>;
1416 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1417 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1419multiset(std::initializer_list<KEY>, COMPARATOR, ALLOC *)
1420-> multiset<KEY, COMPARATOR>;
1429 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1431multiset(std::initializer_list<KEY>, ALLOCATOR)
1432-> multiset<KEY, std::less<KEY>, ALLOCATOR>;
1441 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1442 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1444multiset(std::initializer_list<KEY>, ALLOC *)
1458template <class KEY, class COMPARATOR, class ALLOCATOR>
1459bool operator==(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1460 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1462#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1463template <class KEY, class COMPARATOR, class ALLOCATOR>
1464bool operator!=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1465 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1475#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1480template <class KEY, class COMPARATOR, class ALLOCATOR>
1481BloombergLP::bslalg::SynthThreeWayUtil::Result<KEY>
1482operator<=>(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1483 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1487template <class KEY, class COMPARATOR, class ALLOCATOR>
1488bool operator< (const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1489 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1502template <class KEY, class COMPARATOR, class ALLOCATOR>
1503bool operator> (const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1504 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1513template <class KEY, class COMPARATOR, class ALLOCATOR>
1514bool operator<=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1515 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1524template <class KEY, class COMPARATOR, class ALLOCATOR>
1525bool operator>=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1526 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1541template <class KEY, class COMPARATOR, class ALLOCATOR, class PREDICATE>
1542typename multiset<KEY, COMPARATOR, ALLOCATOR>::size_type
1543erase_if(multiset<KEY, COMPARATOR, ALLOCATOR>& ms, PREDICATE predicate);
1545template <class KEY, class COMPARATOR, class ALLOCATOR>
1546void
swap(multiset<KEY, COMPARATOR, ALLOCATOR>& a,
1547 multiset<KEY, COMPARATOR, ALLOCATOR>& b)
1549 BSLS_KEYWORD_NOEXCEPT_OPERATOR(a.swap(b)));
1577template <class KEY, class COMPARATOR, class ALLOCATOR>
1579multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
1580 const COMPARATOR& comparator,
1581 const ALLOCATOR& basicAllocator)
1583, d_pool(basicAllocator)
1587template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1589multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
1590 BloombergLP::bslmf::MovableRef<DataWrapper> original)
1591: ::
bsl::multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator(
1592 MoveUtil::access(original).keyComparator())
1593, d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
1598template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1600typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1601multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
1607template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1609const typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1610multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
const
1619template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1621typename multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator&
1622multiset<KEY, COMPARATOR, ALLOCATOR>::comparator()
1624 return d_compAndAlloc;
1627template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1629typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1630multiset<KEY, COMPARATOR, ALLOCATOR>::nodeFactory()
1632 return d_compAndAlloc.nodeFactory();
1635template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1637void multiset<KEY, COMPARATOR, ALLOCATOR>::quickSwapExchangeAllocators(
1640 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
1641 nodeFactory().swapExchangeAllocators(other.nodeFactory());
1649 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
1650 comparator().swap(other.comparator());
1654template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1656void multiset<KEY, COMPARATOR, ALLOCATOR>::quickSwapRetainAllocators(
1659 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
1660 nodeFactory().swapRetainAllocators(other.nodeFactory());
1664 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
1665 comparator().swap(other.comparator());
1670template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1672const typename multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator&
1673multiset<KEY, COMPARATOR, ALLOCATOR>::comparator()
const
1675 return d_compAndAlloc;
1678template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1680const typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1681multiset<KEY, COMPARATOR, ALLOCATOR>::nodeFactory()
const
1683 return d_compAndAlloc.nodeFactory();
1687template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1689multiset<KEY, COMPARATOR, ALLOCATOR>::multiset()
1690: d_compAndAlloc(COMPARATOR(), ALLOCATOR())
1695template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1697multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
const ALLOCATOR& basicAllocator)
1698: d_compAndAlloc(COMPARATOR(), basicAllocator)
1703template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1705multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
const multiset& original)
1706: d_compAndAlloc(original.comparator().keyComparator(),
1707 AllocatorTraits::select_on_container_copy_construction(
1708 original.nodeFactory().allocator()))
1711 if (0 < original.size()) {
1712 nodeFactory().reserveNodes(original.size());
1713 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
1719template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1721multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1722 BloombergLP::bslmf::MovableRef<multiset> original)
1723: d_compAndAlloc(MoveUtil::move(MoveUtil::access(original).d_compAndAlloc))
1726 multiset& lvalue = original;
1727 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
1730template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1732multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
const multiset& original,
1733 const typename type_identity<ALLOCATOR>::type& basicAllocator)
1734: d_compAndAlloc(original.comparator().keyComparator(), basicAllocator)
1737 if (0 < original.size()) {
1738 nodeFactory().reserveNodes(original.size());
1739 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
1745template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1747multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1748 BloombergLP::bslmf::MovableRef<multiset> original,
1749 const typename type_identity<ALLOCATOR>::type& basicAllocator)
1750: d_compAndAlloc(MoveUtil::access(original).comparator().keyComparator(),
1754 multiset& lvalue = original;
1757 nodeFactory().allocator() == lvalue.nodeFactory().allocator())) {
1758 d_compAndAlloc.nodeFactory().adopt(
1759 MoveUtil::move(lvalue.d_compAndAlloc.nodeFactory()));
1760 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
1763 if (0 < lvalue.size()) {
1764 nodeFactory().reserveNodes(lvalue.size());
1765 BloombergLP::bslalg::RbTreeUtil::moveTree(&d_tree,
1768 &lvalue.nodeFactory());
1773template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1774template <
class INPUT_ITERATOR>
1776multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1777 INPUT_ITERATOR first,
1778 INPUT_ITERATOR last,
1779 const COMPARATOR& comparator,
1780 const ALLOCATOR& basicAllocator)
1781: d_compAndAlloc(comparator, basicAllocator)
1784 if (first != last) {
1786 size_type numElements =
1787 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
1789 if (0 < numElements) {
1790 nodeFactory().reserveNodes(numElements);
1793 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
1804 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
1805 while (++first != last) {
1808 const value_type& value = *first;
1809 if (this->comparator()(value, *prevNode)) {
1811 insert(++first, last);
1814 BloombergLP::bslalg::RbTreeNode *node =
1815 nodeFactory().emplaceIntoNewNode(value);
1816 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
1827template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1828template <
class INPUT_ITERATOR>
1830multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1831 INPUT_ITERATOR first,
1832 INPUT_ITERATOR last,
1833 const ALLOCATOR& basicAllocator)
1834: d_compAndAlloc(COMPARATOR(), basicAllocator)
1837 if (first != last) {
1839 size_type numElements =
1840 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
1842 if (0 < numElements) {
1843 nodeFactory().reserveNodes(numElements);
1846 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
1857 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
1858 while (++first != last) {
1861 const value_type& value = *first;
1862 if (this->comparator()(value, *prevNode)) {
1864 insert(++first, last);
1867 BloombergLP::bslalg::RbTreeNode *node =
1868 nodeFactory().emplaceIntoNewNode(value);
1869 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
1880#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1881template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1883multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1884 std::initializer_list<KEY> values,
1885 const COMPARATOR& comparator,
1886 const ALLOCATOR& basicAllocator)
1887: multiset(values.
begin(), values.
end(), comparator, basicAllocator)
1891template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1893multiset<KEY, COMPARATOR, ALLOCATOR>::multiset(
1894 std::initializer_list<KEY> values,
1895 const ALLOCATOR& basicAllocator)
1896: multiset(values.
begin(), values.
end(), COMPARATOR(), basicAllocator)
1901template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1903multiset<KEY, COMPARATOR, ALLOCATOR>::~multiset()
1909template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1911multiset<KEY, COMPARATOR, ALLOCATOR>&
1912multiset<KEY, COMPARATOR, ALLOCATOR>::operator=(
const multiset& rhs)
1915 if (AllocatorTraits::propagate_on_container_copy_assignment::value) {
1916 multiset other(rhs, rhs.nodeFactory().allocator());
1917 quickSwapExchangeAllocators(other);
1920 multiset other(rhs, nodeFactory().allocator());
1921 quickSwapRetainAllocators(other);
1927template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1929multiset<KEY, COMPARATOR, ALLOCATOR>&
1930multiset<KEY, COMPARATOR, ALLOCATOR>::operator=(
1931 BloombergLP::bslmf::MovableRef<multiset> rhs)
1933 AllocatorTraits::is_always_equal::value
1934 && std::is_nothrow_move_assignable<COMPARATOR>::value)
1936 multiset& lvalue = rhs;
1939 if (nodeFactory().allocator() == lvalue.nodeFactory().allocator()) {
1940 multiset other(MoveUtil::move(lvalue));
1941 quickSwapRetainAllocators(other);
1944 AllocatorTraits::propagate_on_container_move_assignment::value) {
1945 multiset other(MoveUtil::move(lvalue));
1946 quickSwapExchangeAllocators(other);
1949 multiset other(MoveUtil::move(lvalue), nodeFactory().allocator());
1950 quickSwapRetainAllocators(other);
1956#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1957template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1959multiset<KEY, COMPARATOR, ALLOCATOR>&
1960multiset<KEY, COMPARATOR, ALLOCATOR>::operator=(
1961 std::initializer_list<KEY> values)
1964 insert(values.begin(), values.end());
1969template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1971typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
1974 return iterator(d_tree.firstNode());
1977template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1979typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
1982 return iterator(d_tree.sentinel());
1985template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1987typename multiset<KEY, COMPARATOR, ALLOCATOR>::reverse_iterator
1990 return reverse_iterator(
end());
1993template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1995typename multiset<KEY, COMPARATOR, ALLOCATOR>::reverse_iterator
1998 return reverse_iterator(
begin());
2001template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2003typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2004multiset<KEY, COMPARATOR, ALLOCATOR>::insert(
const value_type& value)
2008 BloombergLP::bslalg::RbTreeNode *insertLocation =
2009 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2014 BloombergLP::bslalg::RbTreeNode *node =
2015 nodeFactory().emplaceIntoNewNode(value);
2017 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2021 return iterator(node);
2024template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2026typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2027multiset<KEY, COMPARATOR, ALLOCATOR>::insert(
2028 BloombergLP::bslmf::MovableRef<value_type> value)
2030 value_type& lvalue = value;
2033 BloombergLP::bslalg::RbTreeNode *insertLocation =
2034 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2039 BloombergLP::bslalg::RbTreeNode *node =
2040 nodeFactory().emplaceIntoNewNode(MoveUtil::move(lvalue));
2042 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2046 return iterator(node);
2049template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2051typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2052multiset<KEY, COMPARATOR, ALLOCATOR>::insert(const_iterator hint,
2053 const value_type& value)
2057 BloombergLP::bslalg::RbTreeNode *hintNode =
2058 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2060 BloombergLP::bslalg::RbTreeNode *insertLocation =
2061 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2067 BloombergLP::bslalg::RbTreeNode *node =
2068 nodeFactory().emplaceIntoNewNode(value);
2070 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2074 return iterator(node);
2077template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2079typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2080multiset<KEY, COMPARATOR, ALLOCATOR>::insert(
2081 const_iterator hint,
2082 BloombergLP::bslmf::MovableRef<value_type> value)
2084 value_type& lvalue = value;
2087 BloombergLP::bslalg::RbTreeNode *hintNode =
2088 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2090 BloombergLP::bslalg::RbTreeNode *insertLocation =
2091 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2097 BloombergLP::bslalg::RbTreeNode *node =
2098 nodeFactory().emplaceIntoNewNode(MoveUtil::move(lvalue));
2100 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2104 return iterator(node);
2107template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2108template <
class INPUT_ITERATOR>
2110void multiset<KEY, COMPARATOR, ALLOCATOR>::insert(INPUT_ITERATOR first,
2111 INPUT_ITERATOR last)
2121 const bool canCalculateInsertDistance =
2122 is_convertible<
typename
2123 iterator_traits<INPUT_ITERATOR>::iterator_category,
2124 forward_iterator_tag>::value;
2126 while (first != last) {
2127 if (canCalculateInsertDistance
2129 !nodeFactory().hasFreeNodes())) {
2130 const size_type numElements =
2131 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2133 nodeFactory().reserveNodes(numElements);
2140#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2141template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2143void multiset<KEY, COMPARATOR, ALLOCATOR>::insert(
2144 std::initializer_list<KEY> values)
2146 insert(values.begin(), values.end());
2150#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2153#ifndef BSLSTL_MULTISET_VARIADIC_LIMIT
2154#define BSLSTL_MULTISET_VARIADIC_LIMIT 10
2156#ifndef BSLSTL_MULTISET_VARIADIC_LIMIT_B
2157#define BSLSTL_MULTISET_VARIADIC_LIMIT_B BSLSTL_MULTISET_VARIADIC_LIMIT
2159#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 0
2160template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2162typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2163multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2168 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2171 BloombergLP::bslalg::RbTreeNode *insertLocation =
2172 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2175 static_cast<const Node *
>(node)->value());
2177 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2181 return iterator(node);
2185#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 1
2186template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2187template <
class Args_01>
2189typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2190multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2195 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2198 BloombergLP::bslalg::RbTreeNode *insertLocation =
2199 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2202 static_cast<const Node *
>(node)->value());
2204 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2208 return iterator(node);
2212#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 2
2213template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2214template <
class Args_01,
2217typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2218multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2224 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2228 BloombergLP::bslalg::RbTreeNode *insertLocation =
2229 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2232 static_cast<const Node *
>(node)->value());
2234 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2238 return iterator(node);
2242#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 3
2243template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2244template <
class Args_01,
2248typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2249multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2256 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2261 BloombergLP::bslalg::RbTreeNode *insertLocation =
2262 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2265 static_cast<const Node *
>(node)->value());
2267 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2271 return iterator(node);
2275#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 4
2276template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2277template <
class Args_01,
2282typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2283multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2291 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2297 BloombergLP::bslalg::RbTreeNode *insertLocation =
2298 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2301 static_cast<const Node *
>(node)->value());
2303 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2307 return iterator(node);
2311#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 5
2312template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2313template <
class Args_01,
2319typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2320multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2329 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2336 BloombergLP::bslalg::RbTreeNode *insertLocation =
2337 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2340 static_cast<const Node *
>(node)->value());
2342 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2346 return iterator(node);
2350#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 6
2351template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2352template <
class Args_01,
2359typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2360multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2370 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2378 BloombergLP::bslalg::RbTreeNode *insertLocation =
2379 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2382 static_cast<const Node *
>(node)->value());
2384 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2388 return iterator(node);
2392#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 7
2393template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2394template <
class Args_01,
2402typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2403multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2414 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2423 BloombergLP::bslalg::RbTreeNode *insertLocation =
2424 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2427 static_cast<const Node *
>(node)->value());
2429 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2433 return iterator(node);
2437#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 8
2438template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2439template <
class Args_01,
2448typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2449multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2461 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2471 BloombergLP::bslalg::RbTreeNode *insertLocation =
2472 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2475 static_cast<const Node *
>(node)->value());
2477 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2481 return iterator(node);
2485#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 9
2486template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2487template <
class Args_01,
2497typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2498multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2511 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2522 BloombergLP::bslalg::RbTreeNode *insertLocation =
2523 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2526 static_cast<const Node *
>(node)->value());
2528 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2532 return iterator(node);
2536#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 10
2537template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2538template <
class Args_01,
2549typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2550multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
2564 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2576 BloombergLP::bslalg::RbTreeNode *insertLocation =
2577 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2580 static_cast<const Node *
>(node)->value());
2582 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2586 return iterator(node);
2591#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 0
2592template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2594typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2595multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint)
2599 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2602 BloombergLP::bslalg::RbTreeNode *hintNode =
2603 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2605 BloombergLP::bslalg::RbTreeNode *insertLocation =
2606 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2609 static_cast<const Node *
>(node)->value(),
2612 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2616 return iterator(node);
2620#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 1
2621template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2622template <
class Args_01>
2624typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2625multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2630 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2633 BloombergLP::bslalg::RbTreeNode *hintNode =
2634 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2636 BloombergLP::bslalg::RbTreeNode *insertLocation =
2637 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2640 static_cast<const Node *
>(node)->value(),
2643 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2647 return iterator(node);
2651#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 2
2652template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2653template <
class Args_01,
2656typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2657multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2663 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2667 BloombergLP::bslalg::RbTreeNode *hintNode =
2668 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2670 BloombergLP::bslalg::RbTreeNode *insertLocation =
2671 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2674 static_cast<const Node *
>(node)->value(),
2677 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2681 return iterator(node);
2685#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 3
2686template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2687template <
class Args_01,
2691typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2692multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2699 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2704 BloombergLP::bslalg::RbTreeNode *hintNode =
2705 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2707 BloombergLP::bslalg::RbTreeNode *insertLocation =
2708 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2711 static_cast<const Node *
>(node)->value(),
2714 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2718 return iterator(node);
2722#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 4
2723template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2724template <
class Args_01,
2729typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2730multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2738 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2744 BloombergLP::bslalg::RbTreeNode *hintNode =
2745 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2747 BloombergLP::bslalg::RbTreeNode *insertLocation =
2748 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2751 static_cast<const Node *
>(node)->value(),
2754 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2758 return iterator(node);
2762#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 5
2763template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2764template <
class Args_01,
2770typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2771multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2780 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2787 BloombergLP::bslalg::RbTreeNode *hintNode =
2788 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2790 BloombergLP::bslalg::RbTreeNode *insertLocation =
2791 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2794 static_cast<const Node *
>(node)->value(),
2797 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2801 return iterator(node);
2805#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 6
2806template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2807template <
class Args_01,
2814typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2815multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2825 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2833 BloombergLP::bslalg::RbTreeNode *hintNode =
2834 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2836 BloombergLP::bslalg::RbTreeNode *insertLocation =
2837 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2840 static_cast<const Node *
>(node)->value(),
2843 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2847 return iterator(node);
2851#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 7
2852template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2853template <
class Args_01,
2861typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2862multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2873 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2882 BloombergLP::bslalg::RbTreeNode *hintNode =
2883 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2885 BloombergLP::bslalg::RbTreeNode *insertLocation =
2886 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2889 static_cast<const Node *
>(node)->value(),
2892 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2896 return iterator(node);
2900#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 8
2901template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2902template <
class Args_01,
2911typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2912multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2924 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2934 BloombergLP::bslalg::RbTreeNode *hintNode =
2935 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2937 BloombergLP::bslalg::RbTreeNode *insertLocation =
2938 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2941 static_cast<const Node *
>(node)->value(),
2944 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2948 return iterator(node);
2952#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 9
2953template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2954template <
class Args_01,
2964typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
2965multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
2978 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2989 BloombergLP::bslalg::RbTreeNode *hintNode =
2990 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2992 BloombergLP::bslalg::RbTreeNode *insertLocation =
2993 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2996 static_cast<const Node *
>(node)->value(),
2999 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
3003 return iterator(node);
3007#if BSLSTL_MULTISET_VARIADIC_LIMIT_B >= 10
3008template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3009template <
class Args_01,
3020typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
3021multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
3035 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
3047 BloombergLP::bslalg::RbTreeNode *hintNode =
3048 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
3050 BloombergLP::bslalg::RbTreeNode *insertLocation =
3051 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
3054 static_cast<const Node *
>(node)->value(),
3057 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
3061 return iterator(node);
3068template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3069template <
class... Args>
3071typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
3072multiset<KEY, COMPARATOR, ALLOCATOR>::emplace(
3077 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
3080 BloombergLP::bslalg::RbTreeNode *insertLocation =
3081 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
3084 static_cast<const Node *
>(node)->value());
3086 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
3090 return iterator(node);
3093template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3094template <
class... Args>
3096typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
3097multiset<KEY, COMPARATOR, ALLOCATOR>::emplace_hint(const_iterator hint,
3102 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
3105 BloombergLP::bslalg::RbTreeNode *hintNode =
3106 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
3108 BloombergLP::bslalg::RbTreeNode *insertLocation =
3109 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
3112 static_cast<const Node *
>(node)->value(),
3115 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
3119 return iterator(node);
3124template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3126typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
3127multiset<KEY, COMPARATOR, ALLOCATOR>::erase(const_iterator position)
3131 BloombergLP::bslalg::RbTreeNode *node =
3132 const_cast<BloombergLP::bslalg::RbTreeNode *
>(position.node());
3133 BloombergLP::bslalg::RbTreeNode *result =
3134 BloombergLP::bslalg::RbTreeUtil::next(node);
3135 BloombergLP::bslalg::RbTreeUtil::remove(&d_tree, node);
3136 nodeFactory().deleteNode(node);
3137 return iterator(result);
3140template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3142typename multiset<KEY, COMPARATOR, ALLOCATOR>::size_type
3143multiset<KEY, COMPARATOR, ALLOCATOR>::erase(
const key_type& key)
3145 size_type count = 0;
3146 const_iterator first = find(key);
3147 if (first !=
end()) {
3148 const_iterator last = upper_bound(key);
3149 while (first != last) {
3150 first =
erase(first);
3157template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3159typename multiset<KEY, COMPARATOR, ALLOCATOR>::iterator
3160multiset<KEY, COMPARATOR, ALLOCATOR>::erase(const_iterator first,
3161 const_iterator last)
3163 while (first != last) {
3164 first =
erase(first);
3166 return iterator(last.node());
3169template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3171void multiset<KEY, COMPARATOR, ALLOCATOR>::swap(multiset& other)
3173 AllocatorTraits::is_always_equal::value
3174 && bsl::is_nothrow_swappable<COMPARATOR>::value)
3176 if (AllocatorTraits::propagate_on_container_swap::value) {
3177 quickSwapExchangeAllocators(other);
3184 nodeFactory().allocator() == other.nodeFactory().allocator())) {
3185 quickSwapRetainAllocators(other);
3190 multiset toOtherCopy(MoveUtil::move(*
this),
3191 other.nodeFactory().allocator());
3192 multiset toThisCopy(MoveUtil::move(other),
3193 nodeFactory().allocator());
3195 other.quickSwapRetainAllocators(toOtherCopy);
3196 this->quickSwapRetainAllocators(toThisCopy);
3201template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3207 if (d_tree.rootNode()) {
3211 BloombergLP::bslalg::RbTreeUtil::deleteTree(&d_tree, &nodeFactory());
3213#if defined(BSLS_ASSERT_SAFE_IS_USED)
3222template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3224typename multiset<KEY, COMPARATOR, ALLOCATOR>::allocator_type
3225multiset<KEY, COMPARATOR, ALLOCATOR>::get_allocator() const
3228 return nodeFactory().allocator();
3231template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3233typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_iterator
3239template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3241typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_iterator
3247template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3249typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_reverse_iterator
3255template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3257typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_reverse_iterator
3263template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3265typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_iterator
3268 return const_iterator(d_tree.firstNode());
3271template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3273typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_iterator
3276 return const_iterator(d_tree.sentinel());
3279template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3281typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_reverse_iterator
3284 return const_reverse_iterator(
end());
3287template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3289typename multiset<KEY, COMPARATOR, ALLOCATOR>::const_reverse_iterator
3292 return const_reverse_iterator(
begin());
3295template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3297bool multiset<KEY, COMPARATOR, ALLOCATOR>::contains(
const key_type& key)
const
3299 return find(key) !=
end();
3303template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3307 return 0 == d_tree.numNodes();
3310template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3312typename multiset<KEY, COMPARATOR, ALLOCATOR>::size_type
3315 return d_tree.numNodes();
3319template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3321typename multiset<KEY, COMPARATOR, ALLOCATOR>::size_type
3324 return AllocatorTraits::max_size(get_allocator());
3327template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3329typename multiset<KEY, COMPARATOR, ALLOCATOR>::key_compare
3330multiset<KEY, COMPARATOR, ALLOCATOR>::key_comp()
const
3332 return comparator().keyComparator();
3335template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3337typename multiset<KEY, COMPARATOR, ALLOCATOR>::value_compare
3338multiset<KEY, COMPARATOR, ALLOCATOR>::value_comp()
const
3340 return value_compare(key_comp());
3346template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3351 return BloombergLP::bslalg::RangeCompare::equal(lhs.
begin(),
3359#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
3360template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3365 return !(lhs == rhs);
3369#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
3371template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3373BloombergLP::bslalg::SynthThreeWayUtil::Result<KEY>
3374bsl::operator<=>(
const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
3375 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs)
3377 return bsl::lexicographical_compare_three_way(
3382 BloombergLP::bslalg::SynthThreeWayUtil::compare);
3387template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3392 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.
begin(),
3400template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3408template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3413 return !(rhs < lhs);
3417template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3422 return !(lhs < rhs);
3428template <
class KEY,
class COMPARATOR,
class ALLOCATOR,
class PREDICATE>
3431bsl::erase_if(multiset<KEY, COMPARATOR, ALLOCATOR>& ms, PREDICATE predicate)
3433 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(ms, predicate);
3436template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3459template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3460struct HasStlIterators<
bsl::multiset<KEY, COMPARATOR, ALLOCATOR> >
3468template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
3469struct UsesBslmaAllocator<
bsl::multiset<KEY, COMPARATOR, ALLOCATOR> >
3478# error Not valid except when included from bslstl_multiset.h
Definition bslma_bslallocator.h:580
Definition bslstl_multiset.h:610
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2595
multiset &operator=(BloombergLP::bslmf::MovableRef< multiset > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2204
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2618
void swap(multiset &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:1107
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2635
BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_type > const_iterator
Definition bslstl_multiset.h:714
value_type & reference
Definition bslstl_multiset.h:701
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_multiset.h:716
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2603
COMPARATOR key_compare
Definition bslstl_multiset.h:698
BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_type > iterator
Definition bslstl_multiset.h:711
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2587
COMPARATOR value_compare
Definition bslstl_multiset.h:699
iterator erase(const_iterator position)
Definition bslstl_multiset.h:2440
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2212
iterator find(const key_type &key)
Definition bslstl_multiset.h:1119
key_compare key_comp() const
Definition bslstl_multiset.h:2643
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this multiset.
Definition bslstl_multiset.h:2626
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2538
multiset()
Definition bslstl_multiset.h:1921
iterator insert(const value_type &value)
Definition bslstl_multiset.h:2236
iterator lower_bound(const key_type &key)
Definition bslstl_multiset.h:1152
KEY value_type
Definition bslstl_multiset.h:697
~multiset()
Destroy this object.
Definition bslstl_multiset.h:2135
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2579
bool contains(const key_type &key) const
Definition bslstl_multiset.h:2610
pair< iterator, iterator > equal_range(const key_type &key)
Definition bslstl_multiset.h:1226
iterator emplace(Args &&... args)
Definition bslstl_multiset.h:2387
value_compare value_comp() const
Definition bslstl_multiset.h:2651
multiset & operator=(const multiset &rhs)
Definition bslstl_multiset.h:2144
KEY key_type
Definition bslstl_multiset.h:696
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2228
iterator upper_bound(const key_type &key)
Definition bslstl_multiset.h:1189
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition bslstl_multiset.h:2411
AllocatorTraits::const_pointer const_pointer
Definition bslstl_multiset.h:707
AllocatorTraits::difference_type difference_type
Definition bslstl_multiset.h:705
size_type count(const key_type &key) const
Definition bslstl_multiset.h:1394
AllocatorTraits::pointer pointer
Definition bslstl_multiset.h:706
ALLOCATOR allocator_type
Definition bslstl_multiset.h:700
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multiset.h:2220
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_multiset.h:715
const value_type & const_reference
Definition bslstl_multiset.h:702
AllocatorTraits::size_type size_type
Definition bslstl_multiset.h:704
#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_OPERATOR(...)
Definition bsls_keyword.h:635
#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)
Definition bdlb_printmethods.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1611
bool operator<(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
T::const_reverse_iterator crbegin(const T &container)
Definition bslstl_iterator.h:1597
bool operator>(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const 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::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1553
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4135
bool operator!=(const memory_resource &a, const memory_resource &b)
T::const_reverse_iterator crend(const T &container)
Definition bslstl_iterator.h:1654
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
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 bslmf_enableif.h:525
Definition bslmf_isconvertible.h:867
t_TYPE type
Definition bslmf_typeidentity.h:216