8#ifndef INCLUDED_BSLSTL_MULTISET
9#define INCLUDED_BSLSTL_MULTISET
526#include <bslscm_version.h>
567#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
568# include <initializer_list>
571#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
575#ifdef BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER
576#include <type_traits>
579#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
583# define COMPILING_BSLSTL_MULTISET_H
585# undef COMPILING_BSLSTL_MULTISET_H
608 class COMPARATOR = std::less<KEY>,
616 typedef const KEY ValueType;
620 typedef BloombergLP::bslstl::SetComparator<KEY, COMPARATOR> Comparator;
624 typedef BloombergLP::bslstl::TreeNode<KEY> Node;
628 typedef BloombergLP::bslstl::TreeNodePool<KEY, ALLOCATOR> NodeFactory;
636 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
647 class DataWrapper :
public Comparator {
654 DataWrapper(
const DataWrapper&);
655 DataWrapper& operator=(
const DataWrapper&);
663 explicit DataWrapper(
const COMPARATOR& comparator,
664 const ALLOCATOR& basicAllocator);
671 DataWrapper(BloombergLP::bslmf::MovableRef<DataWrapper> original);
677 NodeFactory& nodeFactory();
683 const NodeFactory& nodeFactory()
const;
687 DataWrapper d_compAndAlloc;
691 BloombergLP::bslalg::RbTreeAnchor d_tree;
709 typedef BloombergLP::bslstl::TreeIterator<
const value_type,
712 typedef BloombergLP::bslstl::TreeIterator<
const value_type,
723 Comparator& comparator();
727 NodeFactory& nodeFactory();
734 void quickSwapExchangeAllocators(
multiset& other);
742 void quickSwapRetainAllocators(
multiset& other);
748 const Comparator& comparator()
const;
752 const NodeFactory& nodeFactory()
const;
770 const ALLOCATOR& basicAllocator = ALLOCATOR())
771 : d_compAndAlloc(comparator, basicAllocator)
787 explicit multiset(
const ALLOCATOR& basicAllocator);
806 multiset(BloombergLP::bslmf::MovableRef<multiset> original);
831 multiset(BloombergLP::bslmf::MovableRef<multiset> original,
859 template <
class INPUT_ITERATOR>
862 const COMPARATOR& comparator = COMPARATOR(),
863 const ALLOCATOR& basicAllocator = ALLOCATOR());
864 template <
class INPUT_ITERATOR>
867 const ALLOCATOR& basicAllocator);
869#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
870 multiset(std::initializer_list<KEY> values,
871 const COMPARATOR& comparator = COMPARATOR(),
872 const ALLOCATOR& basicAllocator = ALLOCATOR());
891 multiset(std::initializer_list<KEY> values,
892 const ALLOCATOR& basicAllocator);
912 AllocatorTraits::is_always_equal::value
913 && std::is_nothrow_move_assignable<COMPARATOR>::value);
928#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1014 template <class INPUT_ITERATOR>
1015 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
1017#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1022 void insert(std::initializer_list<KEY> values);
1025#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1033 template <
class... Args>
1050 template <
class... Args>
1084 AllocatorTraits::is_always_equal::value
1085 && bsl::is_nothrow_swappable<COMPARATOR>::value);
1121 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
1122 d_tree, this->comparator(), key));
1131 template <
class LOOKUP_KEY>
1133 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1138 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
1139 d_tree, this->comparator(), key));
1154 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1155 d_tree, this->comparator(), key));
1168 template <
class LOOKUP_KEY>
1170 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1175 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1176 d_tree, this->comparator(), key));
1191 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1192 d_tree, this->comparator(), key));
1205 template <
class LOOKUP_KEY>
1207 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1212 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1213 d_tree, this->comparator(), key));
1231 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1247 template <
class LOOKUP_KEY>
1249 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1256 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1322 template <class LOOKUP_KEY>
1324 BloombergLP::
bslmf::IsTransparentPredicate<COMPARATOR,
1370 d_tree, this->comparator(), key));
1379 template <
class LOOKUP_KEY>
1381 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1387 d_tree, this->comparator(), key));
1399 while (it !=
end() && !comparator()(key, *it.node())) {
1410 template <
class LOOKUP_KEY>
1412 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1420 while (it !=
end() && !comparator()(key, *it.node())) {
1439 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1440 d_tree, this->comparator(), key));
1453 template <
class LOOKUP_KEY>
1455 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1460 return const_iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1461 d_tree, this->comparator(), key));
1476 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1477 d_tree, this->comparator(), key));
1490 template <
class LOOKUP_KEY>
1492 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1497 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1498 d_tree, this->comparator(), key));
1517 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1534 template <
class LOOKUP_KEY>
1536 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1543 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1552#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1562 class INPUT_ITERATOR,
1564 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1565 class COMPARATOR = std::less<KEY>,
1567 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1568 class = bsl::enable_if_t<
bsl::IsStdAllocator_v<ALLOCATOR>>
1570multiset(INPUT_ITERATOR,
1572 COMPARATOR = COMPARATOR(),
1573 ALLOCATOR = ALLOCATOR())
1574-> multiset<KEY, COMPARATOR, ALLOCATOR>;
1582 class INPUT_ITERATOR,
1586 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1587 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1588 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1590multiset(INPUT_ITERATOR, INPUT_ITERATOR, COMPARATOR, ALLOC *)
1591-> multiset<KEY, COMPARATOR>;
1599 class INPUT_ITERATOR,
1602 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1603 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1605multiset(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR)
1606-> multiset<KEY, std::less<KEY>, ALLOCATOR>;
1613 class INPUT_ITERATOR,
1616 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1617 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1618 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1620multiset(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1629 class COMPARATOR = std::less<KEY>,
1630 class ALLOCATOR = bsl::allocator<KEY>,
1631 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1632 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1634multiset(std::initializer_list<KEY>,
1635 COMPARATOR = COMPARATOR(),
1636 ALLOCATOR = ALLOCATOR())
1637-> multiset<KEY, COMPARATOR, ALLOCATOR>;
1648 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1649 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1651multiset(std::initializer_list<KEY>, COMPARATOR, ALLOC *)
1652-> multiset<KEY, COMPARATOR>;
1661 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1663multiset(std::initializer_list<KEY>, ALLOCATOR)
1664-> multiset<KEY, std::less<KEY>, ALLOCATOR>;
1673 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1674 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1676multiset(std::initializer_list<KEY>, ALLOC *)
1690template <class KEY, class COMPARATOR, class ALLOCATOR>
1691bool operator==(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1692 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1694#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1695template <class KEY, class COMPARATOR, class ALLOCATOR>
1696bool operator!=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1697 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1707#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1712template <class KEY, class COMPARATOR, class ALLOCATOR>
1713BloombergLP::bslalg::SynthThreeWayUtil::Result<KEY>
1714operator<=>(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1715 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1719template <class KEY, class COMPARATOR, class ALLOCATOR>
1720bool operator< (const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1721 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1734template <class KEY, class COMPARATOR, class ALLOCATOR>
1735bool operator> (const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1736 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1745template <class KEY, class COMPARATOR, class ALLOCATOR>
1746bool operator<=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1747 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1756template <class KEY, class COMPARATOR, class ALLOCATOR>
1757bool operator>=(const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
1758 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs);
1773template <class KEY, class COMPARATOR, class ALLOCATOR, class PREDICATE>
1774typename
multiset<KEY, COMPARATOR, ALLOCATOR>::size_type
1775erase_if(multiset<KEY, COMPARATOR, ALLOCATOR>& ms, PREDICATE predicate);
1777template <class KEY, class COMPARATOR, class ALLOCATOR>
1778void swap(multiset<KEY, COMPARATOR, ALLOCATOR>& a,
1779 multiset<KEY, COMPARATOR, ALLOCATOR>& b)
1781 BSLS_KEYWORD_NOEXCEPT_OPERATOR(a.swap(b)));
1809template <class KEY, class COMPARATOR, class ALLOCATOR>
1811multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
1812 const COMPARATOR& comparator,
1813 const ALLOCATOR& basicAllocator)
1815, d_pool(basicAllocator)
1819template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1821multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
1822 BloombergLP::bslmf::MovableRef<DataWrapper> original)
1823: ::
bsl::multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator(
1824 MoveUtil::access(original).keyComparator())
1825, d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
1830template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1832typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1833multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
1839template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1841const typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1842multiset<KEY, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
const
1851template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1853typename multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator&
1854multiset<KEY, COMPARATOR, ALLOCATOR>::comparator()
1856 return d_compAndAlloc;
1859template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1861typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1862multiset<KEY, COMPARATOR, ALLOCATOR>::nodeFactory()
1864 return d_compAndAlloc.nodeFactory();
1867template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1869void multiset<KEY, COMPARATOR, ALLOCATOR>::quickSwapExchangeAllocators(
1872 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
1873 nodeFactory().swapExchangeAllocators(other.nodeFactory());
1881 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
1882 comparator().swap(other.comparator());
1886template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1888void multiset<KEY, COMPARATOR, ALLOCATOR>::quickSwapRetainAllocators(
1891 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
1892 nodeFactory().swapRetainAllocators(other.nodeFactory());
1896 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
1897 comparator().swap(other.comparator());
1902template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1904const typename multiset<KEY, COMPARATOR, ALLOCATOR>::Comparator&
1905multiset<KEY, COMPARATOR, ALLOCATOR>::comparator()
const
1907 return d_compAndAlloc;
1910template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1912const typename multiset<KEY, COMPARATOR, ALLOCATOR>::NodeFactory&
1913multiset<KEY, COMPARATOR, ALLOCATOR>::nodeFactory()
const
1915 return d_compAndAlloc.nodeFactory();
1919template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1922: d_compAndAlloc(COMPARATOR(), ALLOCATOR())
1927template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1930: d_compAndAlloc(COMPARATOR(), basicAllocator)
1935template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1938: d_compAndAlloc(original.comparator().keyComparator(),
1943 if (0 < original.
size()) {
1944 nodeFactory().reserveNodes(original.
size());
1945 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
1951template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1954 BloombergLP::bslmf::MovableRef<multiset> original)
1955: d_compAndAlloc(MoveUtil::move(MoveUtil::access(original).d_compAndAlloc))
1959 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
1962template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1966: d_compAndAlloc(original.comparator().keyComparator(), basicAllocator)
1969 if (0 < original.
size()) {
1970 nodeFactory().reserveNodes(original.
size());
1971 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
1977template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
1980 BloombergLP::bslmf::MovableRef<multiset> original,
1982: d_compAndAlloc(MoveUtil::access(original).comparator().keyComparator(),
1989 nodeFactory().
allocator() == lvalue.nodeFactory().allocator())) {
1990 d_compAndAlloc.nodeFactory().adopt(
1991 MoveUtil::move(lvalue.d_compAndAlloc.nodeFactory()));
1992 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
1995 if (0 < lvalue.
size()) {
1996 nodeFactory().reserveNodes(lvalue.
size());
1997 BloombergLP::bslalg::RbTreeUtil::moveTree(&d_tree,
2000 &lvalue.nodeFactory());
2005template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2006template <
class INPUT_ITERATOR>
2009 INPUT_ITERATOR first,
2010 INPUT_ITERATOR last,
2011 const COMPARATOR& comparator,
2012 const ALLOCATOR& basicAllocator)
2013: d_compAndAlloc(comparator, basicAllocator)
2016 if (first != last) {
2019 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2021 if (0 < numElements) {
2022 nodeFactory().reserveNodes(numElements);
2025 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
2036 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
2037 while (++first != last) {
2041 if (this->comparator()(value, *prevNode)) {
2046 BloombergLP::bslalg::RbTreeNode *node =
2047 nodeFactory().emplaceIntoNewNode(value);
2048 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2059template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2060template <
class INPUT_ITERATOR>
2063 INPUT_ITERATOR first,
2064 INPUT_ITERATOR last,
2065 const ALLOCATOR& basicAllocator)
2066: d_compAndAlloc(COMPARATOR(), basicAllocator)
2069 if (first != last) {
2072 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2074 if (0 < numElements) {
2075 nodeFactory().reserveNodes(numElements);
2078 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
2089 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
2090 while (++first != last) {
2094 if (this->comparator()(value, *prevNode)) {
2099 BloombergLP::bslalg::RbTreeNode *node =
2100 nodeFactory().emplaceIntoNewNode(value);
2101 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2112#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2113template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2116 std::initializer_list<KEY> values,
2117 const COMPARATOR& comparator,
2118 const ALLOCATOR& basicAllocator)
2123template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2126 std::initializer_list<KEY> values,
2127 const ALLOCATOR& basicAllocator)
2128: multiset(values.
begin(), values.
end(), COMPARATOR(), basicAllocator)
2133template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2141template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2147 if (AllocatorTraits::propagate_on_container_copy_assignment::value) {
2148 multiset other(rhs, rhs.nodeFactory().allocator());
2149 quickSwapExchangeAllocators(other);
2153 quickSwapRetainAllocators(other);
2159template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2163 BloombergLP::bslmf::MovableRef<multiset> rhs)
2165 AllocatorTraits::is_always_equal::value
2166 && std::is_nothrow_move_assignable<COMPARATOR>::value)
2171 if (nodeFactory().
allocator() == lvalue.nodeFactory().allocator()) {
2172 multiset other(MoveUtil::move(lvalue));
2173 quickSwapRetainAllocators(other);
2176 AllocatorTraits::propagate_on_container_move_assignment::value) {
2177 multiset other(MoveUtil::move(lvalue));
2178 quickSwapExchangeAllocators(other);
2181 multiset other(MoveUtil::move(lvalue), nodeFactory().allocator());
2182 quickSwapRetainAllocators(other);
2188#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2189template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2191multiset<KEY, COMPARATOR, ALLOCATOR>&
2193 std::initializer_list<KEY> values)
2196 insert(values.begin(), values.end());
2201template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2206 return iterator(d_tree.firstNode());
2209template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2214 return iterator(d_tree.sentinel());
2217template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2225template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2233template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2240 BloombergLP::bslalg::RbTreeNode *insertLocation =
2241 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2246 BloombergLP::bslalg::RbTreeNode *node =
2247 nodeFactory().emplaceIntoNewNode(value);
2249 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2256template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2260 BloombergLP::bslmf::MovableRef<value_type> value)
2265 BloombergLP::bslalg::RbTreeNode *insertLocation =
2266 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2271 BloombergLP::bslalg::RbTreeNode *node =
2272 nodeFactory().emplaceIntoNewNode(MoveUtil::move(lvalue));
2274 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2281template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2289 BloombergLP::bslalg::RbTreeNode *hintNode =
2290 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2292 BloombergLP::bslalg::RbTreeNode *insertLocation =
2293 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2299 BloombergLP::bslalg::RbTreeNode *node =
2300 nodeFactory().emplaceIntoNewNode(value);
2302 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2309template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2314 BloombergLP::bslmf::MovableRef<value_type> value)
2319 BloombergLP::bslalg::RbTreeNode *hintNode =
2320 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2322 BloombergLP::bslalg::RbTreeNode *insertLocation =
2323 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2329 BloombergLP::bslalg::RbTreeNode *node =
2330 nodeFactory().emplaceIntoNewNode(MoveUtil::move(lvalue));
2332 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2339template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2340template <
class INPUT_ITERATOR>
2343 INPUT_ITERATOR last)
2353 const bool canCalculateInsertDistance =
2355 iterator_traits<INPUT_ITERATOR>::iterator_category,
2356 forward_iterator_tag>::value;
2358 while (first != last) {
2359 if (canCalculateInsertDistance
2361 !nodeFactory().hasFreeNodes())) {
2363 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2365 nodeFactory().reserveNodes(numElements);
2372#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2373template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2376 std::initializer_list<KEY> values)
2378 insert(values.begin(), values.end());
2382#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2383template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2384template <
class... Args>
2391 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2394 BloombergLP::bslalg::RbTreeNode *insertLocation =
2395 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2398 static_cast<const Node *
>(node)->value());
2400 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2407template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2408template <
class... Args>
2416 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2419 BloombergLP::bslalg::RbTreeNode *hintNode =
2420 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2422 BloombergLP::bslalg::RbTreeNode *insertLocation =
2423 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2426 static_cast<const Node *
>(node)->value(),
2429 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2437template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2444 BloombergLP::bslalg::RbTreeNode *node =
2445 const_cast<BloombergLP::bslalg::RbTreeNode *
>(position.node());
2446 BloombergLP::bslalg::RbTreeNode *result =
2447 BloombergLP::bslalg::RbTreeUtil::next(node);
2448 BloombergLP::bslalg::RbTreeUtil::remove(&d_tree, node);
2449 nodeFactory().deleteNode(node);
2453template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2460 if (first !=
end()) {
2462 while (first != last) {
2463 first =
erase(first);
2470template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2476 while (first != last) {
2477 first =
erase(first);
2482template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2486 AllocatorTraits::is_always_equal::value
2487 && bsl::is_nothrow_swappable<COMPARATOR>::value)
2489 if (AllocatorTraits::propagate_on_container_swap::value) {
2490 quickSwapExchangeAllocators(other);
2497 nodeFactory().allocator() == other.nodeFactory().allocator())) {
2498 quickSwapRetainAllocators(other);
2503 multiset toOtherCopy(MoveUtil::move(*
this),
2504 other.nodeFactory().allocator());
2505 multiset toThisCopy(MoveUtil::move(other),
2506 nodeFactory().allocator());
2508 other.quickSwapRetainAllocators(toOtherCopy);
2509 this->quickSwapRetainAllocators(toThisCopy);
2514template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2520 if (d_tree.rootNode()) {
2524 BloombergLP::bslalg::RbTreeUtil::deleteTree(&d_tree, &nodeFactory());
2526#if defined(BSLS_ASSERT_SAFE_IS_USED)
2535template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2541 return nodeFactory().allocator();
2544template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2552template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2560template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2568template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2576template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2584template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2592template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2600template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2608template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2612 return find(key) !=
end();
2616template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2620 return 0 == d_tree.numNodes();
2623template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2628 return d_tree.numNodes();
2632template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2637 return AllocatorTraits::max_size(get_allocator());
2640template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2645 return comparator().keyComparator();
2648template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2659template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2664 return BloombergLP::bslalg::RangeCompare::equal(lhs.
begin(),
2672#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2673template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2678 return !(lhs == rhs);
2682#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2684template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2686BloombergLP::bslalg::SynthThreeWayUtil::Result<KEY>
2687bsl::operator<=>(
const multiset<KEY, COMPARATOR, ALLOCATOR>& lhs,
2688 const multiset<KEY, COMPARATOR, ALLOCATOR>& rhs)
2690 return bsl::lexicographical_compare_three_way(
2695 BloombergLP::bslalg::SynthThreeWayUtil::compare);
2700template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2705 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.
begin(),
2713template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2721template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2726 return !(rhs < lhs);
2730template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2735 return !(lhs < rhs);
2741template <
class KEY,
class COMPARATOR,
class ALLOCATOR,
class PREDICATE>
2744bsl::erase_if(multiset<KEY, COMPARATOR, ALLOCATOR>& ms, PREDICATE predicate)
2746 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(ms, predicate);
2749template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2772template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
2781template <
class KEY,
class COMPARATOR,
class ALLOCATOR>
Definition bslma_bslallocator.h:580
Definition bslstl_multiset.h:610
multiset(const COMPARATOR &comparator, const ALLOCATOR &basicAllocator=ALLOCATOR())
Definition bslstl_multiset.h:769
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
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< iterator, iterator > >::type equal_range(const LOOKUP_KEY &key)
Definition bslstl_multiset.h:1252
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
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, size_type >::type count(const LOOKUP_KEY &key) const
Definition bslstl_multiset.h:1415
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
const_iterator upper_bound(const key_type &key) const
Definition bslstl_multiset.h:1474
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
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type find(const LOOKUP_KEY &key)
Definition bslstl_multiset.h:1136
iterator upper_bound(const key_type &key)
Definition bslstl_multiset.h:1189
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< const_iterator, const_iterator > >::type equal_range(const LOOKUP_KEY &key) const
Definition bslstl_multiset.h:1539
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition bslstl_multiset.h:2411
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type upper_bound(const LOOKUP_KEY &key)
Definition bslstl_multiset.h:1210
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
const_iterator lower_bound(const key_type &key) const
Definition bslstl_multiset.h:1437
AllocatorTraits::pointer pointer
Definition bslstl_multiset.h:706
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type lower_bound(const LOOKUP_KEY &key)
Definition bslstl_multiset.h:1173
ALLOCATOR allocator_type
Definition bslstl_multiset.h:700
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type upper_bound(const LOOKUP_KEY &key) const
Definition bslstl_multiset.h:1495
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
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type lower_bound(const LOOKUP_KEY &key) const
Definition bslstl_multiset.h:1458
pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition bslstl_multiset.h:1512
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type find(const LOOKUP_KEY &key) const
Definition bslstl_multiset.h:1384
AllocatorTraits::size_type size_type
Definition bslstl_multiset.h:704
Definition bslstl_pair.h:1210
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#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
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
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
Definition bslalg_hasstliterators.h:99
Definition bslma_usesbslmaallocator.h:343