8#ifndef INCLUDED_BSLSTL_MULTIMAP
9#define INCLUDED_BSLSTL_MULTIMAP
577#include <bslscm_version.h>
616#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
617# include <initializer_list>
620#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
624#ifdef BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER
625#include <type_traits>
626 #ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
627 #error Rvalue references curiously absent despite native 'type_traits'.
631#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
635# define COMPILING_BSLSTL_MULTIMAP_H
637# undef COMPILING_BSLSTL_MULTIMAP_H
663 class COMPARATOR = std::less<KEY>,
664 class ALLOCATOR = allocator<pair<const KEY, VALUE> > >
675 typedef BloombergLP::bslstl::MapComparator<KEY, VALUE, COMPARATOR>
680 typedef BloombergLP::bslstl::TreeNode<ValueType> Node;
684 typedef BloombergLP::bslstl::TreeNodePool<ValueType, ALLOCATOR>
693 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
704 class DataWrapper :
public Comparator {
711 DataWrapper(
const DataWrapper&);
712 DataWrapper& operator=(
const DataWrapper&);
720 DataWrapper(
const COMPARATOR& comparator,
721 const ALLOCATOR& basicAllocator);
729 BloombergLP::bslmf::MovableRef<DataWrapper> original);
735 NodeFactory& nodeFactory();
741 const NodeFactory& nodeFactory()
const;
745 DataWrapper d_compAndAlloc;
749 BloombergLP::bslalg::RbTreeAnchor d_tree;
767 typedef BloombergLP::bslstl::TreeIterator<
value_type,
771 typedef BloombergLP::bslstl::TreeIterator<
const value_type,
848 static Node *toNode(BloombergLP::bslalg::RbTreeNode *node);
853 static const Node *toNode(
const BloombergLP::bslalg::RbTreeNode *node);
859 Comparator& comparator();
863 NodeFactory& nodeFactory();
870 void quickSwapExchangeAllocators(
multimap& other);
878 void quickSwapRetainAllocators(
multimap& other);
884 const Comparator& comparator()
const;
888 const NodeFactory& nodeFactory()
const;
906 const ALLOCATOR& basicAllocator = ALLOCATOR())
907 : d_compAndAlloc(comparator, basicAllocator)
923 explicit multimap(
const ALLOCATOR& basicAllocator);
942 multimap(BloombergLP::bslmf::MovableRef<multimap> original);
967 multimap(BloombergLP::bslmf::MovableRef<multimap> original,
996 template <
class INPUT_ITERATOR>
999 const COMPARATOR& comparator = COMPARATOR(),
1000 const ALLOCATOR& basicAllocator = ALLOCATOR());
1001 template <
class INPUT_ITERATOR>
1003 INPUT_ITERATOR last,
1004 const ALLOCATOR& basicAllocator);
1006#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1007 multimap(std::initializer_list<value_type> values,
1008 const COMPARATOR& comparator = COMPARATOR(),
1009 const ALLOCATOR& basicAllocator = ALLOCATOR());
1028 multimap(std::initializer_list<value_type> values,
1029 const ALLOCATOR& basicAllocator);
1050 AllocatorTraits::is_always_equal::value &&
1051 std::is_nothrow_move_assignable<COMPARATOR>::value);
1067#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1108#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
1109 template <
class ALT_VALUE_TYPE>
1111#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
1112 template <
class ALT_VALUE_TYPE>
1125 template <
class ALT_VALUE_TYPE>
1127 ALT_VALUE_TYPE&&>::value,
1151#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
1152 template <
class ALT_VALUE_TYPE>
1154#elif !defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
1155 template <
class ALT_VALUE_TYPE>
1172 template <
class ALT_VALUE_TYPE>
1174 ALT_VALUE_TYPE&&>::value,
1198 template <
class INPUT_ITERATOR>
1199 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
1201#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
1216#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1222 void insert(std::initializer_list<value_type> values);
1225#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1235 template <
class... Args>
1252 template <
class... Args>
1286 AllocatorTraits::is_always_equal::value &&
1287 bsl::is_nothrow_swappable<COMPARATOR>::value);
1323 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
1324 d_tree, this->comparator(), key));
1333 template <
class LOOKUP_KEY>
1335 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1340 return iterator(BloombergLP::bslalg::RbTreeUtil::find(
1341 d_tree, this->comparator(), key));
1356 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1357 d_tree, this->comparator(), key));
1370 template <
class LOOKUP_KEY>
1372 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1377 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1378 d_tree, this->comparator(), key));
1393 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1394 d_tree, this->comparator(), key));
1407 template <
class LOOKUP_KEY>
1409 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1414 return iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1415 d_tree, this->comparator(), key));
1433 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1450 template <
class LOOKUP_KEY>
1452 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1459 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1525 template <class LOOKUP_KEY>
1527 BloombergLP::
bslmf::IsTransparentPredicate<COMPARATOR,
1574 d_tree, this->comparator(), key));
1583 template <
class LOOKUP_KEY>
1585 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1591 d_tree, this->comparator(), key));
1603 while (it !=
end() && !comparator()(key, *it.node())) {
1614 template <
class LOOKUP_KEY>
1616 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1624 while (it !=
end() && !comparator()(key, *it.node())) {
1644 return iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1645 d_tree, this->comparator(), key));
1659 template <
class LOOKUP_KEY>
1661 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1666 return const_iterator(BloombergLP::bslalg::RbTreeUtil::lowerBound(
1667 d_tree, this->comparator(), key));
1682 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1683 d_tree, this->comparator(), key));
1696 template <
class LOOKUP_KEY>
1698 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1703 return const_iterator(BloombergLP::bslalg::RbTreeUtil::upperBound(
1704 d_tree, this->comparator(), key));
1722 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1739 template <
class LOOKUP_KEY>
1741 BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR,
1748 if (endIt !=
end() && !comparator()(key, *endIt.node())) {
1757#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1767 class INPUT_ITERATOR,
1768 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1770 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1771 class COMPARATOR = std::less<KEY>,
1773 BloombergLP::bslstl::IteratorUtil::IterToAlloc_t<INPUT_ITERATOR>>,
1774 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1775 class = bsl::enable_if_t<
bsl::IsStdAllocator_v<ALLOCATOR>>
1777multimap(INPUT_ITERATOR,
1779 COMPARATOR = COMPARATOR(),
1780 ALLOCATOR = ALLOCATOR())
1781-> multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>;
1790 class INPUT_ITERATOR,
1793 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1795 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1796 class DEFAULT_ALLOCATOR = bsl::allocator<pair<const KEY, VALUE>>,
1797 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1799multimap(INPUT_ITERATOR, INPUT_ITERATOR, COMPARATOR, ALLOC *)
1800-> multimap<KEY, VALUE, COMPARATOR>;
1807 class INPUT_ITERATOR,
1809 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1811 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1812 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1814multimap(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR)
1815-> multimap<KEY, VALUE, std::less<KEY>, ALLOCATOR>;
1822 class INPUT_ITERATOR,
1824 class KEY = BloombergLP::bslstl::IteratorUtil::IterKey_t<INPUT_ITERATOR>,
1826 BloombergLP::bslstl::IteratorUtil::IterMapped_t<INPUT_ITERATOR>,
1827 class DEFAULT_ALLOCATOR = bsl::allocator<pair<const KEY, VALUE>>,
1828 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1830multimap(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1831-> multimap<KEY, VALUE>;
1842 class COMPARATOR = std::less<KEY>,
1843 class ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1844 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<COMPARATOR>>,
1845 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1847multimap(std::initializer_list<pair<const KEY, VALUE>>,
1848 COMPARATOR = COMPARATOR(),
1849 ALLOCATOR = ALLOCATOR())
1850-> multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>;
1863 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1864 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1866multimap(std::initializer_list<pair<const KEY, VALUE>>, COMPARATOR, ALLOC *)
1867-> multimap<KEY, VALUE, COMPARATOR>;
1879 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1881multimap(std::initializer_list<pair<const KEY, VALUE>>, ALLOCATOR)
1882-> multimap<KEY, VALUE, std::less<KEY>, ALLOCATOR>;
1892 class DEFAULT_ALLOCATOR = bsl::allocator<bsl::pair<const KEY, VALUE>>,
1893 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1895multimap(std::initializer_list<pair<const KEY, VALUE>>, ALLOC *)
1896-> multimap<KEY, VALUE>;
1909template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1910bool operator==(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1911 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1913#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1914template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1915bool operator!=(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1916 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1927#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1933template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1934BloombergLP::bslalg::SynthThreeWayUtil::Result<pair<const KEY, VALUE>>
1935operator<=>(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1936 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1940template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1941bool operator<(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1942 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1955template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1956bool operator>(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1957 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1966template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1967bool operator<=(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1968 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
1977template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
1978bool operator>=(const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
1979 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs);
2009template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
2010void swap(multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& a,
2011 multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& b)
2023template <class KEY, class VALUE, class COMPARATOR, class ALLOCATOR>
2025multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
2026 const COMPARATOR& comparator,
2027 const ALLOCATOR& basicAllocator)
2028:
::bsl::multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::Comparator(comparator)
2029, d_pool(basicAllocator)
2033template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2035multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::DataWrapper::DataWrapper(
2036 BloombergLP::bslmf::MovableRef<DataWrapper> original)
2037: ::
bsl::multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::Comparator(
2038 MoveUtil::access(original).keyComparator())
2039, d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
2044template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2046typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::NodeFactory&
2047multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
2053template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2055const typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::NodeFactory&
2056multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::DataWrapper::nodeFactory()
const
2065template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2068 COMPARATOR comparator)
2073template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2087template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2089typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::Comparator&
2092 return d_compAndAlloc;
2095template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2097typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::NodeFactory&
2100 return d_compAndAlloc.nodeFactory();
2103template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2105void multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::quickSwapExchangeAllocators(
2108 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
2109 nodeFactory().swapExchangeAllocators(other.nodeFactory());
2117 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
2118 comparator().swap(other.comparator());
2122template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2124void multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::quickSwapRetainAllocators(
2127 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &other.d_tree);
2128 nodeFactory().swapRetainAllocators(other.nodeFactory());
2132 if (
sizeof(NodeFactory) !=
sizeof(DataWrapper)) {
2133 comparator().swap(other.comparator());
2138template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2140const typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::Comparator&
2141multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::comparator()
const
2143 return d_compAndAlloc;
2146template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2148const typename multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::NodeFactory&
2149multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>::nodeFactory()
const
2151 return d_compAndAlloc.nodeFactory();
2155template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2158: d_compAndAlloc(COMPARATOR(), ALLOCATOR())
2163template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2166 const ALLOCATOR& basicAllocator)
2167: d_compAndAlloc(COMPARATOR(), basicAllocator)
2172template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2175: d_compAndAlloc(original.comparator().keyComparator(),
2180 if (0 < original.
size()) {
2181 nodeFactory().reserveNodes(original.
size());
2182 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
2188template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2191 BloombergLP::bslmf::MovableRef<multimap> original)
2192: d_compAndAlloc(MoveUtil::move(MoveUtil::access(original).d_compAndAlloc))
2196 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
2199template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2204: d_compAndAlloc(original.comparator().keyComparator(), basicAllocator)
2207 if (0 < original.
size()) {
2208 nodeFactory().reserveNodes(original.
size());
2209 BloombergLP::bslalg::RbTreeUtil::copyTree(&d_tree,
2215template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2218 BloombergLP::bslmf::MovableRef<multimap> original,
2220: d_compAndAlloc(MoveUtil::access(original).comparator().keyComparator(),
2227 nodeFactory().
allocator() == lvalue.nodeFactory().allocator())) {
2228 d_compAndAlloc.nodeFactory().adopt(
2229 MoveUtil::move(lvalue.d_compAndAlloc.nodeFactory()));
2230 BloombergLP::bslalg::RbTreeUtil::swap(&d_tree, &lvalue.d_tree);
2233 if (0 < lvalue.
size()) {
2234 nodeFactory().reserveNodes(lvalue.
size());
2235 BloombergLP::bslalg::RbTreeUtil::moveTree(&d_tree,
2238 &lvalue.nodeFactory());
2243template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2244template <
class INPUT_ITERATOR>
2247 INPUT_ITERATOR first,
2248 INPUT_ITERATOR last,
2249 const COMPARATOR& comparator,
2250 const ALLOCATOR& basicAllocator)
2251: d_compAndAlloc(comparator, basicAllocator)
2254 if (first != last) {
2257 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2259 if (0 < numElements) {
2260 nodeFactory().reserveNodes(numElements);
2263 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
2274 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
2275 while (++first != last) {
2279 if (this->comparator()(value.
first, *prevNode)) {
2284 BloombergLP::bslalg::RbTreeNode *node =
2285 nodeFactory().emplaceIntoNewNode(value);
2286 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2296template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2297template <
class INPUT_ITERATOR>
2300 INPUT_ITERATOR first,
2301 INPUT_ITERATOR last,
2302 const ALLOCATOR& basicAllocator)
2303: d_compAndAlloc(COMPARATOR(), basicAllocator)
2306 if (first != last) {
2309 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2311 if (0 < numElements) {
2312 nodeFactory().reserveNodes(numElements);
2315 BloombergLP::bslalg::RbTreeUtilTreeProctor<NodeFactory> proctor(
2326 BloombergLP::bslalg::RbTreeNode *prevNode = d_tree.rootNode();
2327 while (++first != last) {
2331 if (this->comparator()(value.
first, *prevNode)) {
2336 BloombergLP::bslalg::RbTreeNode *node =
2337 nodeFactory().emplaceIntoNewNode(value);
2338 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2348#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2349template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2352 std::initializer_list<value_type> values,
2353 const COMPARATOR& comparator,
2354 const ALLOCATOR& basicAllocator)
2359template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2362 std::initializer_list<value_type> values,
2363 const ALLOCATOR& basicAllocator)
2364: multimap(values.
begin(), values.
end(), COMPARATOR(), basicAllocator)
2369template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2377template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2383 if (AllocatorTraits::propagate_on_container_copy_assignment::value) {
2384 multimap other(rhs, rhs.nodeFactory().allocator());
2385 quickSwapExchangeAllocators(other);
2389 quickSwapRetainAllocators(other);
2395template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2399 BloombergLP::bslmf::MovableRef<multimap> rhs)
2401 AllocatorTraits::is_always_equal::value &&
2402 std::is_nothrow_move_assignable<COMPARATOR>::value)
2407 if (nodeFactory().
allocator() == lvalue.nodeFactory().allocator()) {
2408 multimap other(MoveUtil::move(lvalue));
2409 quickSwapRetainAllocators(other);
2412 AllocatorTraits::propagate_on_container_move_assignment::value) {
2413 multimap other(MoveUtil::move(lvalue));
2414 quickSwapExchangeAllocators(other);
2417 multimap other(MoveUtil::move(lvalue), nodeFactory().allocator());
2418 quickSwapRetainAllocators(other);
2424#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2425template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2427multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>&
2429 std::initializer_list<value_type> values)
2432 insert(values.begin(), values.end());
2437template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2442 return iterator(d_tree.firstNode());
2445template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2450 return iterator(d_tree.sentinel());
2453template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2461template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2469template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2476 BloombergLP::bslalg::RbTreeNode *insertLocation =
2477 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2482 BloombergLP::bslalg::RbTreeNode *node =
2483 nodeFactory().emplaceIntoNewNode(value);
2485 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2492template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2493template <
class INPUT_ITERATOR>
2496 INPUT_ITERATOR last)
2506 const bool canCalculateInsertDistance =
2508 iterator_traits<INPUT_ITERATOR>::iterator_category,
2509 forward_iterator_tag>::value;
2511 while (first != last) {
2512 if (canCalculateInsertDistance
2514 !nodeFactory().hasFreeNodes())) {
2516 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2518 nodeFactory().reserveNodes(numElements);
2525#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
2526template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2529 const_iterator last)
2531 while (first != last) {
2538template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2546 BloombergLP::bslalg::RbTreeNode *hintNode =
2547 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2549 BloombergLP::bslalg::RbTreeNode *insertLocation =
2550 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(&leftChild,
2556 BloombergLP::bslalg::RbTreeNode *node =
2557 nodeFactory().emplaceIntoNewNode(value);
2559 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2566#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2567template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2570 std::initializer_list<value_type> values)
2572 insert(values.begin(), values.end());
2576#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2577template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2578template <
class... Args>
2585 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2588 BloombergLP::bslalg::RbTreeNode *insertLocation =
2589 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(
2593 static_cast<const Node *
>(node)->value().first);
2595 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2602template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2603template <
class... Args>
2611 BloombergLP::bslalg::RbTreeNode *node = nodeFactory().emplaceIntoNewNode(
2614 BloombergLP::bslalg::RbTreeNode *hintNode =
2615 const_cast<BloombergLP::bslalg::RbTreeNode *
>(hint.node());
2617 BloombergLP::bslalg::RbTreeNode *insertLocation =
2618 BloombergLP::bslalg::RbTreeUtil::findInsertLocation(
2622 static_cast<const Node *
>(node)->value().first,
2625 BloombergLP::bslalg::RbTreeUtil::insertAt(&d_tree,
2634template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2641 BloombergLP::bslalg::RbTreeNode *node =
2642 const_cast<BloombergLP::bslalg::RbTreeNode *
>(position.node());
2643 BloombergLP::bslalg::RbTreeNode *result =
2644 BloombergLP::bslalg::RbTreeUtil::next(node);
2645 BloombergLP::bslalg::RbTreeUtil::remove(&d_tree, node);
2646 nodeFactory().deleteNode(node);
2650template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2658template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2666 if (first !=
end()) {
2668 while (first != last) {
2669 first =
erase(first);
2676template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2682 while (first != last) {
2683 first =
erase(first);
2688template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2692 AllocatorTraits::is_always_equal::value &&
2693 bsl::is_nothrow_swappable<COMPARATOR>::value)
2695 if (AllocatorTraits::propagate_on_container_swap::value) {
2696 quickSwapExchangeAllocators(other);
2703 nodeFactory().allocator() == other.nodeFactory().allocator())) {
2704 quickSwapRetainAllocators(other);
2709 multimap toOtherCopy(MoveUtil::move(*
this),
2710 other.nodeFactory().allocator());
2711 multimap toThisCopy( MoveUtil::move(other),
2712 nodeFactory().allocator());
2714 this->quickSwapRetainAllocators(toThisCopy);
2715 other.quickSwapRetainAllocators(toOtherCopy);
2720template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2726 if (d_tree.rootNode()) {
2730 BloombergLP::bslalg::RbTreeUtil::deleteTree(&d_tree, &nodeFactory());
2732#if defined(BSLS_ASSERT_SAFE_IS_USED)
2741template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2747 return nodeFactory().allocator();
2750template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2760template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2769template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2778template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2786template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2795template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2803template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2812template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2821template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2826 return find(key) !=
end();
2830template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2835 return 0 == d_tree.numNodes();
2838template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2843 return d_tree.numNodes();
2846template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2852 return AllocatorTraits::max_size(get_allocator());
2855template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2860 return comparator().keyComparator();
2863template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2874template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2876bool bsl::operator==(
2880 return BloombergLP::bslalg::RangeCompare::equal(lhs.
begin(),
2888#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2889template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2895 return !(lhs == rhs);
2899#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2901template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2903BloombergLP::bslalg::SynthThreeWayUtil::Result<bsl::pair<const KEY, VALUE>>
2904bsl::operator<=>(
const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& lhs,
2905 const multimap<KEY, VALUE, COMPARATOR, ALLOCATOR>& rhs)
2907 return bsl::lexicographical_compare_three_way(
2912 BloombergLP::bslalg::SynthThreeWayUtil::compare);
2917template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2923 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.
begin(),
2931template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2940template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2946 return !(rhs < lhs);
2950template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2956 return !(lhs < rhs);
2962template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2984template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
2994template <
class KEY,
class VALUE,
class COMPARATOR,
class ALLOCATOR>
Definition bslma_bslallocator.h:580
Definition bslstl_multimap.h:786
COMPARATOR comp
Definition bslstl_multimap.h:793
value_compare & operator=(const value_compare &rhs)=default
bool operator()(const value_type &x, const value_type &y) const
Definition bslstl_multimap.h:2075
value_type first_argument_type
Definition bslstl_multimap.h:813
bool result_type
Definition bslstl_multimap.h:808
value_type second_argument_type
Definition bslstl_multimap.h:818
value_compare(const value_compare &original)=default
Definition bslstl_multimap.h:665
void swap(multimap &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:1309
AllocatorTraits::difference_type difference_type
Definition bslstl_multimap.h:763
pair< const KEY, VALUE > value_type
Definition bslstl_multimap.h:756
bool contains(const key_type &key) const
Definition bslstl_multimap.h:2823
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_multimap.h:1744
const_iterator upper_bound(const key_type &key) const
Definition bslstl_multimap.h:1680
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_multimap.h:776
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2849
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this multimap.
Definition bslstl_multimap.h:2841
bsl::pair< iterator, iterator > equal_range(const key_type &key)
Definition bslstl_multimap.h:1429
const value_type & const_reference
Definition bslstl_multimap.h:760
COMPARATOR key_compare
Definition bslstl_multimap.h:757
iterator emplace(Args &&... args)
Definition bslstl_multimap.h:2581
AllocatorTraits::const_pointer const_pointer
Definition bslstl_multimap.h:765
AllocatorTraits::size_type size_type
Definition bslstl_multimap.h:762
iterator insert(const value_type &value)
Definition bslstl_multimap.h:2472
BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_type > const_iterator
Definition bslstl_multimap.h:773
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type find(const LOOKUP_KEY &key) const
Definition bslstl_multimap.h:1588
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2806
enable_if< is_convertible< ALT_VALUE_TYPE, value_type >::value, iterator >::type insert(BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value)
Definition bslstl_multimap.h:1130
iterator erase(const_iterator position)
Definition bslstl_multimap.h:2637
BloombergLP::bslstl::TreeIterator< value_type, Node, difference_type > iterator
Definition bslstl_multimap.h:769
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type find(const LOOKUP_KEY &key)
Definition bslstl_multimap.h:1338
const_iterator lower_bound(const key_type &key) const
Definition bslstl_multimap.h:1642
multimap & operator=(const multimap &rhs)
Definition bslstl_multimap.h:2380
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, size_type >::type count(const LOOKUP_KEY &key) const
Definition bslstl_multimap.h:1619
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_multimap.h:775
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2832
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2456
pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition bslstl_multimap.h:1718
ALLOCATOR allocator_type
Definition bslstl_multimap.h:758
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2744
~multimap()
Destroy this object.
Definition bslstl_multimap.h:2371
AllocatorTraits::pointer pointer
Definition bslstl_multimap.h:764
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition bslstl_multimap.h:2606
value_compare value_comp() const
Definition bslstl_multimap.h:2866
iterator lower_bound(const key_type &key)
Definition bslstl_multimap.h:1354
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2798
multimap(const COMPARATOR &comparator, const ALLOCATOR &basicAllocator=ALLOCATOR())
Definition bslstl_multimap.h:905
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2448
key_compare key_comp() const
Definition bslstl_multimap.h:2858
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2815
iterator find(const key_type &key)
Definition bslstl_multimap.h:1321
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type upper_bound(const LOOKUP_KEY &key)
Definition bslstl_multimap.h:1412
size_type count(const key_type &key) const
Definition bslstl_multimap.h:1598
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2789
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type lower_bound(const LOOKUP_KEY &key) const
Definition bslstl_multimap.h:1664
multimap()
Definition bslstl_multimap.h:2157
VALUE mapped_type
Definition bslstl_multimap.h:755
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type lower_bound(const LOOKUP_KEY &key)
Definition bslstl_multimap.h:1375
KEY key_type
Definition bslstl_multimap.h:754
iterator upper_bound(const key_type &key)
Definition bslstl_multimap.h:1391
value_type & reference
Definition bslstl_multimap.h:759
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< iterator, iterator > >::type equal_range(const LOOKUP_KEY &key)
Definition bslstl_multimap.h:1455
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type upper_bound(const LOOKUP_KEY &key) const
Definition bslstl_multimap.h:1701
enable_if< is_convertible< ALT_VALUE_TYPE, value_type >::value, iterator >::type insert(const_iterator hint, BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value)
Definition bslstl_multimap.h:1177
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2464
multimap &operator=(BloombergLP::bslmf::MovableRef< multimap > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_multimap.h:2440
Definition bslstl_pair.h:1210
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#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
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
TYPE first
Definition bslstl_pair.h:605
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