libstdc++: stl_multimap.h Source File

libstdc++

stl_multimap.h
Go to the documentation of this file.
1// Multimap implementation -*- C++ -*-
2
3// Copyright (C) 2001-2026 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/*
26 *
27 * Copyright (c) 1994
28 * Hewlett-Packard Company
29 *
30 * Permission to use, copy, modify, distribute and sell this software
31 * and its documentation for any purpose is hereby granted without fee,
32 * provided that the above copyright notice appear in all copies and
33 * that both that copyright notice and this permission notice appear
34 * in supporting documentation. Hewlett-Packard Company makes no
35 * representations about the suitability of this software for any
36 * purpose. It is provided "as is" without express or implied warranty.
37 *
38 *
39 * Copyright (c) 1996,1997
40 * Silicon Graphics Computer Systems, Inc.
41 *
42 * Permission to use, copy, modify, distribute and sell this software
43 * and its documentation for any purpose is hereby granted without fee,
44 * provided that the above copyright notice appear in all copies and
45 * that both that copyright notice and this permission notice appear
46 * in supporting documentation. Silicon Graphics makes no
47 * representations about the suitability of this software for any
48 * purpose. It is provided "as is" without express or implied warranty.
49 */
50
51/** @file bits/stl_multimap.h
52 * This is an internal header file, included by other library headers.
53 * Do not attempt to use it directly. @headername{map}
54 */
55
56#ifndef _STL_MULTIMAP_H
57#define _STL_MULTIMAP_H 1
58
59#include <bits/concept_check.h>
60#if __cplusplus >= 201103L
61#include <initializer_list>
62#endif
63#if __glibcxx_containers_ranges // C++ >= 23
64# include <bits/ranges_base.h> // ranges::begin, ranges::distance etc.
65#endif
66// #include <bits/stl_tree.h> // done in std/map
67
68namespace std _GLIBCXX_VISIBILITY(default)
69{
70_GLIBCXX_BEGIN_NAMESPACE_VERSION
71_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
72
73 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
74 class map;
75
76 /**
77 * @brief A standard container made up of (key,value) pairs, which can be
78 * retrieved based on a key, in logarithmic time.
79 *
80 * @ingroup associative_containers
81 * @headerfile map
82 * @since C++98
83 *
84 * @tparam _Key Type of key objects.
85 * @tparam _Tp Type of mapped objects.
86 * @tparam _Compare Comparison function object type, defaults to less<_Key>.
87 * @tparam _Alloc Allocator type, defaults to
88 * allocator<pair<const _Key, _Tp>.
89 *
90 * Meets the requirements of a <a href="tables.html#65">container</a>, a
91 * <a href="tables.html#66">reversible container</a>, and an
92 * <a href="tables.html#69">associative container</a> (using equivalent
93 * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
94 * is T, and the value_type is std::pair<const Key,T>.
95 *
96 * Multimaps support bidirectional iterators.
97 *
98 * The private tree data is declared exactly the same way for map and
99 * multimap; the distinction is made entirely in how the tree functions are
100 * called (*_unique versus *_equal, same as the standard).
101 */
102 template <typename _Key, typename _Tp,
103 typename _Compare = std::less<_Key>,
104 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
105 class multimap
106 {
107 public:
108 typedef _Key key_type;
109 typedef _Tp mapped_type;
110 typedef std::pair<const _Key, _Tp> value_type;
111 typedef _Compare key_compare;
112 typedef _Alloc allocator_type;
113
114 private:
115#ifdef _GLIBCXX_CONCEPT_CHECKS
116 // concept requirements
117 typedef typename _Alloc::value_type _Alloc_value_type;
118# if __cplusplus < 201103L
119 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
120# endif
121 __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
122 _BinaryFunctionConcept)
123 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
124#endif
125
126#if __cplusplus >= 201103L
127#if __cplusplus > 201703L || defined __STRICT_ANSI__
128 static_assert(is_same<typename _Alloc::value_type, value_type>::value,
129 "std::multimap must have the same value_type as its allocator");
130#endif
131#endif
132
133 public:
134#pragma GCC diagnostic push
135#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
136 class value_compare
137 : public std::binary_function<value_type, value_type, bool>
138 {
139 friend class multimap<_Key, _Tp, _Compare, _Alloc>;
140 protected:
141 _Compare comp;
142
143 value_compare(_Compare __c)
144 : comp(__c) { }
145
146 public:
147 bool operator()(const value_type& __x, const value_type& __y) const
148 { return comp(__x.first, __y.first); }
149 };
150#pragma GCC diagnostic pop
151
152 private:
153 /// This turns a red-black tree into a [multi]map.
154 typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
155 rebind<value_type>::other _Pair_alloc_type;
156
157 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
158 key_compare, _Pair_alloc_type> _Rep_type;
159 /// The actual tree structure.
160 _Rep_type _M_t;
161
162 typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits;
163
164 public:
165 // many of these are specified differently in ISO, but the following are
166 // "functionally equivalent"
167 typedef typename _Alloc_traits::pointer pointer;
168 typedef typename _Alloc_traits::const_pointer const_pointer;
169 typedef typename _Alloc_traits::reference reference;
170 typedef typename _Alloc_traits::const_reference const_reference;
171 typedef typename _Rep_type::iterator iterator;
172 typedef typename _Rep_type::const_iterator const_iterator;
173 typedef typename _Rep_type::size_type size_type;
174 typedef typename _Rep_type::difference_type difference_type;
175 typedef typename _Rep_type::reverse_iterator reverse_iterator;
176 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
177
178#ifdef __glibcxx_node_extract // >= C++17
179 using node_type = typename _Rep_type::node_type;
180#endif
181
182 // [23.3.2] construct/copy/destroy
183 // (get_allocator() is also listed in this section)
184
185 /**
186 * @brief Default constructor creates no elements.
187 */
188#if __cplusplus < 201103L
189 multimap() : _M_t() { }
190#else
191 multimap() = default;
192#endif
193
194 /**
195 * @brief Creates a %multimap with no elements.
196 * @param __comp A comparison object.
197 * @param __a An allocator object.
198 */
199 explicit
200 multimap(const _Compare& __comp,
201 const allocator_type& __a = allocator_type())
202 : _M_t(__comp, _Pair_alloc_type(__a)) { }
203
204 /**
205 * @brief %Multimap copy constructor.
206 *
207 * Whether the allocator is copied depends on the allocator traits.
208 */
209#if __cplusplus < 201103L
210 multimap(const multimap& __x)
211 : _M_t(__x._M_t) { }
212#else
213 multimap(const multimap&) = default;
214
215 /**
216 * @brief %Multimap move constructor.
217 *
218 * The newly-created %multimap contains the exact contents of the
219 * moved instance. The moved instance is a valid, but unspecified
220 * %multimap.
221 */
222 multimap(multimap&&) = default;
223
224 /**
225 * @brief Builds a %multimap from an initializer_list.
226 * @param __l An initializer_list.
227 * @param __comp A comparison functor.
228 * @param __a An allocator object.
229 *
230 * Create a %multimap consisting of copies of the elements from
231 * the initializer_list. This is linear in N if the list is already
232 * sorted, and NlogN otherwise (where N is @a __l.size()).
233 */
234 multimap(initializer_list<value_type> __l,
235 const _Compare& __comp = _Compare(),
236 const allocator_type& __a = allocator_type())
237 : _M_t(__comp, _Pair_alloc_type(__a))
238 { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
239
240 /// Allocator-extended default constructor.
241 explicit
242 multimap(const allocator_type& __a)
243 : _M_t(_Pair_alloc_type(__a)) { }
244
245 /// Allocator-extended copy constructor.
246 multimap(const multimap& __m,
247 const __type_identity_t<allocator_type>& __a)
248 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
249
250 /// Allocator-extended move constructor.
251 multimap(multimap&& __m, const __type_identity_t<allocator_type>& __a)
252 noexcept(is_nothrow_copy_constructible<_Compare>::value
253 && _Alloc_traits::_S_always_equal())
254 : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { }
255
256 /// Allocator-extended initializer-list constructor.
257 multimap(initializer_list<value_type> __l, const allocator_type& __a)
258 : _M_t(_Pair_alloc_type(__a))
259 { _M_t._M_insert_range_equal(__l.begin(), __l.end()); }
260
261 /// Allocator-extended range constructor.
262 template<typename _InputIterator>
263 multimap(_InputIterator __first, _InputIterator __last,
264 const allocator_type& __a)
265 : _M_t(_Pair_alloc_type(__a))
266 { _M_t._M_insert_range_equal(__first, __last); }
267#endif
268
269 /**
270 * @brief Builds a %multimap from a range.
271 * @param __first An input iterator.
272 * @param __last An input iterator.
273 *
274 * Create a %multimap consisting of copies of the elements from
275 * [__first,__last). This is linear in N if the range is already sorted,
276 * and NlogN otherwise (where N is distance(__first,__last)).
277 */
278 template<typename _InputIterator>
279 multimap(_InputIterator __first, _InputIterator __last)
280 : _M_t()
281 { _M_t._M_insert_range_equal(__first, __last); }
282
283 /**
284 * @brief Builds a %multimap from a range.
285 * @param __first An input iterator.
286 * @param __last An input iterator.
287 * @param __comp A comparison functor.
288 * @param __a An allocator object.
289 *
290 * Create a %multimap consisting of copies of the elements from
291 * [__first,__last). This is linear in N if the range is already sorted,
292 * and NlogN otherwise (where N is distance(__first,__last)).
293 */
294 template<typename _InputIterator>
295 multimap(_InputIterator __first, _InputIterator __last,
296 const _Compare& __comp,
297 const allocator_type& __a = allocator_type())
298 : _M_t(__comp, _Pair_alloc_type(__a))
299 { _M_t._M_insert_range_equal(__first, __last); }
300
301#if __glibcxx_containers_ranges // C++ >= 23
302 /**
303 * @brief Builds a %multimap from a range.
304 * @since C++23
305 */
306 template<__detail::__container_compatible_range<value_type> _Rg>
307 multimap(from_range_t, _Rg&& __rg,
308 const _Compare& __comp,
309 const _Alloc& __a = _Alloc())
310 : _M_t(__comp, _Pair_alloc_type(__a))
311 { insert_range(std::forward<_Rg>(__rg)); }
312
313 /// Allocator-extended range constructor.
314 template<__detail::__container_compatible_range<value_type> _Rg>
315 multimap(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc())
316 : _M_t(_Pair_alloc_type(__a))
317 { insert_range(std::forward<_Rg>(__rg)); }
318#endif
319
320
321#if __cplusplus >= 201103L
322 /**
323 * The dtor only erases the elements, and note that if the elements
324 * themselves are pointers, the pointed-to memory is not touched in any
325 * way. Managing the pointer is the user's responsibility.
326 */
327 ~multimap() = default;
328#endif
329
330 /**
331 * @brief %Multimap assignment operator.
332 *
333 * Whether the allocator is copied depends on the allocator traits.
334 */
335#if __cplusplus < 201103L
336 multimap&
337 operator=(const multimap& __x)
338 {
339 _M_t = __x._M_t;
340 return *this;
341 }
342#else
343 multimap&
344 operator=(const multimap&) = default;
345
346 /// Move assignment operator.
347 multimap&
348 operator=(multimap&&) = default;
349
350 /**
351 * @brief %Multimap list assignment operator.
352 * @param __l An initializer_list.
353 *
354 * This function fills a %multimap with copies of the elements
355 * in the initializer list @a __l.
356 *
357 * Note that the assignment completely changes the %multimap and
358 * that the resulting %multimap's size is the same as the number
359 * of elements assigned.
360 */
361 multimap&
362 operator=(initializer_list<value_type> __l)
363 {
364 _M_t._M_assign_equal(__l.begin(), __l.end());
365 return *this;
366 }
367#endif
368
369 /// Get a copy of the memory allocation object.
370 allocator_type
371 get_allocator() const _GLIBCXX_NOEXCEPT
372 { return allocator_type(_M_t.get_allocator()); }
373
374 // iterators
375 /**
376 * Returns a read/write iterator that points to the first pair in the
377 * %multimap. Iteration is done in ascending order according to the
378 * keys.
379 */
380 iterator
381 begin() _GLIBCXX_NOEXCEPT
382 { return _M_t.begin(); }
383
384 /**
385 * Returns a read-only (constant) iterator that points to the first pair
386 * in the %multimap. Iteration is done in ascending order according to
387 * the keys.
388 */
389 const_iterator
390 begin() const _GLIBCXX_NOEXCEPT
391 { return _M_t.begin(); }
392
393 /**
394 * Returns a read/write iterator that points one past the last pair in
395 * the %multimap. Iteration is done in ascending order according to the
396 * keys.
397 */
398 iterator
399 end() _GLIBCXX_NOEXCEPT
400 { return _M_t.end(); }
401
402 /**
403 * Returns a read-only (constant) iterator that points one past the last
404 * pair in the %multimap. Iteration is done in ascending order according
405 * to the keys.
406 */
407 const_iterator
408 end() const _GLIBCXX_NOEXCEPT
409 { return _M_t.end(); }
410
411 /**
412 * Returns a read/write reverse iterator that points to the last pair in
413 * the %multimap. Iteration is done in descending order according to the
414 * keys.
415 */
416 reverse_iterator
417 rbegin() _GLIBCXX_NOEXCEPT
418 { return _M_t.rbegin(); }
419
420 /**
421 * Returns a read-only (constant) reverse iterator that points to the
422 * last pair in the %multimap. Iteration is done in descending order
423 * according to the keys.
424 */
425 const_reverse_iterator
426 rbegin() const _GLIBCXX_NOEXCEPT
427 { return _M_t.rbegin(); }
428
429 /**
430 * Returns a read/write reverse iterator that points to one before the
431 * first pair in the %multimap. Iteration is done in descending order
432 * according to the keys.
433 */
434 reverse_iterator
435 rend() _GLIBCXX_NOEXCEPT
436 { return _M_t.rend(); }
437
438 /**
439 * Returns a read-only (constant) reverse iterator that points to one
440 * before the first pair in the %multimap. Iteration is done in
441 * descending order according to the keys.
442 */
443 const_reverse_iterator
444 rend() const _GLIBCXX_NOEXCEPT
445 { return _M_t.rend(); }
446
447#if __cplusplus >= 201103L
448 /**
449 * Returns a read-only (constant) iterator that points to the first pair
450 * in the %multimap. Iteration is done in ascending order according to
451 * the keys.
452 */
453 const_iterator
454 cbegin() const noexcept
455 { return _M_t.begin(); }
456
457 /**
458 * Returns a read-only (constant) iterator that points one past the last
459 * pair in the %multimap. Iteration is done in ascending order according
460 * to the keys.
461 */
462 const_iterator
463 cend() const noexcept
464 { return _M_t.end(); }
465
466 /**
467 * Returns a read-only (constant) reverse iterator that points to the
468 * last pair in the %multimap. Iteration is done in descending order
469 * according to the keys.
470 */
471 const_reverse_iterator
472 crbegin() const noexcept
473 { return _M_t.rbegin(); }
474
475 /**
476 * Returns a read-only (constant) reverse iterator that points to one
477 * before the first pair in the %multimap. Iteration is done in
478 * descending order according to the keys.
479 */
480 const_reverse_iterator
481 crend() const noexcept
482 { return _M_t.rend(); }
483#endif
484
485 // capacity
486 /** Returns true if the %multimap is empty. */
487 _GLIBCXX_NODISCARD bool
488 empty() const _GLIBCXX_NOEXCEPT
489 { return _M_t.empty(); }
490
491 /** Returns the size of the %multimap. */
492 size_type
493 size() const _GLIBCXX_NOEXCEPT
494 { return _M_t.size(); }
495
496 /** Returns the maximum size of the %multimap. */
497 size_type
498 max_size() const _GLIBCXX_NOEXCEPT
499 { return _M_t.max_size(); }
500
501 // modifiers
502#if __cplusplus >= 201103L
503 /**
504 * @brief Build and insert a std::pair into the %multimap.
505 *
506 * @param __args Arguments used to generate a new pair instance (see
507 * std::piecewise_contruct for passing arguments to each
508 * part of the pair constructor).
509 *
510 * @return An iterator that points to the inserted (key,value) pair.
511 *
512 * This function builds and inserts a (key, value) %pair into the
513 * %multimap.
514 * Contrary to a std::map the %multimap does not rely on unique keys and
515 * thus multiple pairs with the same key can be inserted.
516 *
517 * Insertion requires logarithmic time.
518 */
519 template<typename... _Args>
520 iterator
521 emplace(_Args&&... __args)
522 { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
523
524 /**
525 * @brief Builds and inserts a std::pair into the %multimap.
526 *
527 * @param __pos An iterator that serves as a hint as to where the pair
528 * should be inserted.
529 * @param __args Arguments used to generate a new pair instance (see
530 * std::piecewise_contruct for passing arguments to each
531 * part of the pair constructor).
532 * @return An iterator that points to the inserted (key,value) pair.
533 *
534 * This function inserts a (key, value) pair into the %multimap.
535 * Contrary to a std::map the %multimap does not rely on unique keys and
536 * thus multiple pairs with the same key can be inserted.
537 * Note that the first parameter is only a hint and can potentially
538 * improve the performance of the insertion process. A bad hint would
539 * cause no gains in efficiency.
540 *
541 * For more on @a hinting, see:
542 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
543 *
544 * Insertion requires logarithmic time (if the hint is not taken).
545 */
546 template<typename... _Args>
547 iterator
548 emplace_hint(const_iterator __pos, _Args&&... __args)
549 {
550 return _M_t._M_emplace_hint_equal(__pos,
551 std::forward<_Args>(__args)...);
552 }
553#endif
554
555 /**
556 * @brief Inserts a std::pair into the %multimap.
557 * @param __x Pair to be inserted (see std::make_pair for easy creation
558 * of pairs).
559 * @return An iterator that points to the inserted (key,value) pair.
560 *
561 * This function inserts a (key, value) pair into the %multimap.
562 * Contrary to a std::map the %multimap does not rely on unique keys and
563 * thus multiple pairs with the same key can be inserted.
564 *
565 * Insertion requires logarithmic time.
566 * @{
567 */
568 iterator
569 insert(const value_type& __x)
570 { return _M_t._M_insert_equal(__x); }
571
572#if __cplusplus >= 201103L
573 // _GLIBCXX_RESOLVE_LIB_DEFECTS
574 // 2354. Unnecessary copying when inserting into maps with braced-init
575 iterator
576 insert(value_type&& __x)
577 { return _M_t._M_insert_equal(std::move(__x)); }
578
579 template<typename _Pair>
580 __enable_if_t<is_constructible<value_type, _Pair>::value, iterator>
581 insert(_Pair&& __x)
582 { return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); }
583#endif
584 /// @}
585
586 /**
587 * @brief Inserts a std::pair into the %multimap.
588 * @param __position An iterator that serves as a hint as to where the
589 * pair should be inserted.
590 * @param __x Pair to be inserted (see std::make_pair for easy creation
591 * of pairs).
592 * @return An iterator that points to the inserted (key,value) pair.
593 *
594 * This function inserts a (key, value) pair into the %multimap.
595 * Contrary to a std::map the %multimap does not rely on unique keys and
596 * thus multiple pairs with the same key can be inserted.
597 * Note that the first parameter is only a hint and can potentially
598 * improve the performance of the insertion process. A bad hint would
599 * cause no gains in efficiency.
600 *
601 * For more on @a hinting, see:
602 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
603 *
604 * Insertion requires logarithmic time (if the hint is not taken).
605 * @{
606 */
607 iterator
608#if __cplusplus >= 201103L
609 insert(const_iterator __position, const value_type& __x)
610#else
611 insert(iterator __position, const value_type& __x)
612#endif
613 { return _M_t._M_insert_equal_(__position, __x); }
614
615#if __cplusplus >= 201103L
616 // _GLIBCXX_RESOLVE_LIB_DEFECTS
617 // 2354. Unnecessary copying when inserting into maps with braced-init
618 iterator
619 insert(const_iterator __position, value_type&& __x)
620 { return _M_t._M_insert_equal_(__position, std::move(__x)); }
621
622 template<typename _Pair>
623 __enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator>
624 insert(const_iterator __position, _Pair&& __x)
625 {
626 return _M_t._M_emplace_hint_equal(__position,
627 std::forward<_Pair>(__x));
628 }
629#endif
630 /// @}
631
632 /**
633 * @brief A template function that attempts to insert a range
634 * of elements.
635 * @param __first Iterator pointing to the start of the range to be
636 * inserted.
637 * @param __last Iterator pointing to the end of the range.
638 *
639 * Complexity similar to that of the range constructor.
640 */
641 template<typename _InputIterator>
642 void
643 insert(_InputIterator __first, _InputIterator __last)
644 { _M_t._M_insert_range_equal(__first, __last); }
645
646#if __cplusplus >= 201103L
647 /**
648 * @brief Attempts to insert a list of std::pairs into the %multimap.
649 * @param __l A std::initializer_list<value_type> of pairs to be
650 * inserted.
651 *
652 * Complexity similar to that of the range constructor.
653 */
654 void
655 insert(initializer_list<value_type> __l)
656 { this->insert(__l.begin(), __l.end()); }
657#endif
658
659#if __glibcxx_containers_ranges // C++ >= 23
660 /**
661 * @brief Inserts a range of elements.
662 * @since C++23
663 * @param __rg An input range of elements that can be converted to
664 * the map's value type.
665 */
666 template<__detail::__container_compatible_range<value_type> _Rg>
667 void
668 insert_range(_Rg&& __rg)
669 {
670 auto __first = ranges::begin(__rg);
671 const auto __last = ranges::end(__rg);
672 for (; __first != __last; ++__first)
673 _M_t._M_emplace_equal(*__first);
674 }
675#endif
676
677
678#ifdef __glibcxx_node_extract // >= C++17
679 /// Extract a node.
680 node_type
681 extract(const_iterator __pos)
682 {
683 __glibcxx_assert(__pos != end());
684 return _M_t.extract(__pos);
685 }
686
687 /// Extract a node.
688 node_type
689 extract(const key_type& __x)
690 { return _M_t.extract(__x); }
691
692#ifdef __glibcxx_associative_heterogeneous_erasure // C++23
693 template <__heterogeneous_tree_key<multimap> _Kt>
694 node_type
695 extract(_Kt&& __key)
696 { return _M_t._M_extract_tr(__key); }
697#endif
698
699 /// Re-insert an extracted node.
700 iterator
701 insert(node_type&& __nh)
702 { return _M_t._M_reinsert_node_equal(std::move(__nh)); }
703
704 /// Re-insert an extracted node.
705 iterator
706 insert(const_iterator __hint, node_type&& __nh)
707 { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); }
708
709 template<typename, typename>
710 friend struct std::_Rb_tree_merge_helper;
711
712 template<typename _Cmp2>
713 void
714 merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source)
715 {
716 using _Merge_helper = _Rb_tree_merge_helper<multimap, _Cmp2>;
717 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
718 }
719
720 template<typename _Cmp2>
721 void
722 merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source)
723 { merge(__source); }
724
725 template<typename _Cmp2>
726 void
727 merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source)
728 {
729 using _Merge_helper = _Rb_tree_merge_helper<multimap, _Cmp2>;
730 _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source));
731 }
732
733 template<typename _Cmp2>
734 void
735 merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source)
736 { merge(__source); }
737#endif // C++17
738
739#if __cplusplus >= 201103L
740 // _GLIBCXX_RESOLVE_LIB_DEFECTS
741 // DR 130. Associative erase should return an iterator.
742 /**
743 * @brief Erases an element from a %multimap.
744 * @param __position An iterator pointing to the element to be erased.
745 * @return An iterator pointing to the element immediately following
746 * @a position prior to the element being erased. If no such
747 * element exists, end() is returned.
748 *
749 * This function erases an element, pointed to by the given iterator,
750 * from a %multimap. Note that this function only erases the element,
751 * and that if the element is itself a pointer, the pointed-to memory is
752 * not touched in any way. Managing the pointer is the user's
753 * responsibility.
754 *
755 * @{
756 */
757 iterator
758 erase(const_iterator __position)
759 { return _M_t.erase(__position); }
760
761 // LWG 2059.
762 _GLIBCXX_ABI_TAG_CXX11
763 iterator
764 erase(iterator __position)
765 { return _M_t.erase(__position); }
766 /// @}
767#else
768 /**
769 * @brief Erases an element from a %multimap.
770 * @param __position An iterator pointing to the element to be erased.
771 *
772 * This function erases an element, pointed to by the given iterator,
773 * from a %multimap. Note that this function only erases the element,
774 * and that if the element is itself a pointer, the pointed-to memory is
775 * not touched in any way. Managing the pointer is the user's
776 * responsibility.
777 */
778 void
779 erase(iterator __position)
780 { _M_t.erase(__position); }
781#endif
782
783 /**
784 * @brief Erases elements according to the provided key.
785 * @param __x Key of element to be erased.
786 * @return The number of elements erased.
787 *
788 * This function erases all elements located by the given key from a
789 * %multimap.
790 * Note that this function only erases the element, and that if
791 * the element is itself a pointer, the pointed-to memory is not touched
792 * in any way. Managing the pointer is the user's responsibility.
793 */
794 size_type
795 erase(const key_type& __x)
796 { return _M_t.erase(__x); }
797
798#ifdef __glibcxx_associative_heterogeneous_erasure // C++23
799 template <__heterogeneous_tree_key<multimap> _Kt>
800 size_type
801 erase(_Kt&& __key)
802 { return _M_t._M_erase_tr(__key); }
803#endif
804
805#if __cplusplus >= 201103L
806 // _GLIBCXX_RESOLVE_LIB_DEFECTS
807 // DR 130. Associative erase should return an iterator.
808 /**
809 * @brief Erases a [first,last) range of elements from a %multimap.
810 * @param __first Iterator pointing to the start of the range to be
811 * erased.
812 * @param __last Iterator pointing to the end of the range to be
813 * erased .
814 * @return The iterator @a __last.
815 *
816 * This function erases a sequence of elements from a %multimap.
817 * Note that this function only erases the elements, and that if
818 * the elements themselves are pointers, the pointed-to memory is not
819 * touched in any way. Managing the pointer is the user's
820 * responsibility.
821 */
822 iterator
823 erase(const_iterator __first, const_iterator __last)
824 { return _M_t.erase(__first, __last); }
825#else
826 // _GLIBCXX_RESOLVE_LIB_DEFECTS
827 // DR 130. Associative erase should return an iterator.
828 /**
829 * @brief Erases a [first,last) range of elements from a %multimap.
830 * @param __first Iterator pointing to the start of the range to be
831 * erased.
832 * @param __last Iterator pointing to the end of the range to
833 * be erased.
834 *
835 * This function erases a sequence of elements from a %multimap.
836 * Note that this function only erases the elements, and that if
837 * the elements themselves are pointers, the pointed-to memory is not
838 * touched in any way. Managing the pointer is the user's
839 * responsibility.
840 */
841 void
842 erase(iterator __first, iterator __last)
843 { _M_t.erase(__first, __last); }
844#endif
845
846 /**
847 * @brief Swaps data with another %multimap.
848 * @param __x A %multimap of the same element and allocator types.
849 *
850 * This exchanges the elements between two multimaps in constant time.
851 * (It is only swapping a pointer, an integer, and an instance of
852 * the @c Compare type (which itself is often stateless and empty), so it
853 * should be quite fast.)
854 * Note that the global std::swap() function is specialized such that
855 * std::swap(m1,m2) will feed to this function.
856 *
857 * Whether the allocators are swapped depends on the allocator traits.
858 */
859 void
860 swap(multimap& __x)
861 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
862 { _M_t.swap(__x._M_t); }
863
864 /**
865 * Erases all elements in a %multimap. Note that this function only
866 * erases the elements, and that if the elements themselves are pointers,
867 * the pointed-to memory is not touched in any way. Managing the pointer
868 * is the user's responsibility.
869 */
870 void
871 clear() _GLIBCXX_NOEXCEPT
872 { _M_t.clear(); }
873
874 // observers
875 /**
876 * Returns the key comparison object out of which the %multimap
877 * was constructed.
878 */
879 key_compare
880 key_comp() const
881 { return _M_t.key_comp(); }
882
883 /**
884 * Returns a value comparison object, built from the key comparison
885 * object out of which the %multimap was constructed.
886 */
887 value_compare
888 value_comp() const
889 { return value_compare(_M_t.key_comp()); }
890
891 // multimap operations
892
893 ///@{
894 /**
895 * @brief Tries to locate an element in a %multimap.
896 * @param __x Key of (key, value) pair to be located.
897 * @return Iterator pointing to sought-after element,
898 * or end() if not found.
899 *
900 * This function takes a key and tries to locate the element with which
901 * the key matches. If successful the function returns an iterator
902 * pointing to the sought after %pair. If unsuccessful it returns the
903 * past-the-end ( @c end() ) iterator.
904 */
905 iterator
906 find(const key_type& __x)
907 { return _M_t.find(__x); }
908
909#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
910 template<typename _Kt>
911 auto
912 find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
913 { return _M_t._M_find_tr(__x); }
914#endif
915 ///@}
916
917 ///@{
918 /**
919 * @brief Tries to locate an element in a %multimap.
920 * @param __x Key of (key, value) pair to be located.
921 * @return Read-only (constant) iterator pointing to sought-after
922 * element, or end() if not found.
923 *
924 * This function takes a key and tries to locate the element with which
925 * the key matches. If successful the function returns a constant
926 * iterator pointing to the sought after %pair. If unsuccessful it
927 * returns the past-the-end ( @c end() ) iterator.
928 */
929 const_iterator
930 find(const key_type& __x) const
931 { return _M_t.find(__x); }
932
933#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
934 template<typename _Kt>
935 auto
936 find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
937 { return _M_t._M_find_tr(__x); }
938#endif
939 ///@}
940
941 ///@{
942 /**
943 * @brief Finds the number of elements with given key.
944 * @param __x Key of (key, value) pairs to be located.
945 * @return Number of elements with specified key.
946 */
947 size_type
948 count(const key_type& __x) const
949 { return _M_t.count(__x); }
950
951#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
952 template<typename _Kt>
953 auto
954 count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
955 { return _M_t._M_count_tr(__x); }
956#endif
957 ///@}
958
959#if __cplusplus > 201703L
960 ///@{
961 /**
962 * @brief Finds whether an element with the given key exists.
963 * @param __x Key of (key, value) pairs to be located.
964 * @return True if there is any element with the specified key.
965 */
966 bool
967 contains(const key_type& __x) const
968 { return _M_t.find(__x) != _M_t.end(); }
969
970 template<typename _Kt>
971 auto
972 contains(const _Kt& __x) const
973 -> decltype(_M_t._M_find_tr(__x), void(), true)
974 { return _M_t._M_find_tr(__x) != _M_t.end(); }
975 ///@}
976#endif
977
978 ///@{
979 /**
980 * @brief Finds the beginning of a subsequence matching given key.
981 * @param __x Key of (key, value) pair to be located.
982 * @return Iterator pointing to first element equal to or greater
983 * than key, or end().
984 *
985 * This function returns the first element of a subsequence of elements
986 * that matches the given key. If unsuccessful it returns an iterator
987 * pointing to the first element that has a greater value than given key
988 * or end() if no such element exists.
989 */
990 iterator
991 lower_bound(const key_type& __x)
992 { return _M_t.lower_bound(__x); }
993
994#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
995 template<typename _Kt>
996 auto
997 lower_bound(const _Kt& __x)
998 -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
999 { return iterator(_M_t._M_lower_bound_tr(__x)); }
1000#endif
1001 ///@}
1002
1003 ///@{
1004 /**
1005 * @brief Finds the beginning of a subsequence matching given key.
1006 * @param __x Key of (key, value) pair to be located.
1007 * @return Read-only (constant) iterator pointing to first element
1008 * equal to or greater than key, or end().
1009 *
1010 * This function returns the first element of a subsequence of
1011 * elements that matches the given key. If unsuccessful the
1012 * iterator will point to the next greatest element or, if no
1013 * such greater element exists, to end().
1014 */
1015 const_iterator
1016 lower_bound(const key_type& __x) const
1017 { return _M_t.lower_bound(__x); }
1018
1019#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
1020 template<typename _Kt>
1021 auto
1022 lower_bound(const _Kt& __x) const
1023 -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
1024 { return const_iterator(_M_t._M_lower_bound_tr(__x)); }
1025#endif
1026 ///@}
1027
1028 ///@{
1029 /**
1030 * @brief Finds the end of a subsequence matching given key.
1031 * @param __x Key of (key, value) pair to be located.
1032 * @return Iterator pointing to the first element
1033 * greater than key, or end().
1034 */
1035 iterator
1036 upper_bound(const key_type& __x)
1037 { return _M_t.upper_bound(__x); }
1038
1039#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
1040 template<typename _Kt>
1041 auto
1042 upper_bound(const _Kt& __x)
1043 -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
1044 { return iterator(_M_t._M_upper_bound_tr(__x)); }
1045#endif
1046 ///@}
1047
1048 ///@{
1049 /**
1050 * @brief Finds the end of a subsequence matching given key.
1051 * @param __x Key of (key, value) pair to be located.
1052 * @return Read-only (constant) iterator pointing to first iterator
1053 * greater than key, or end().
1054 */
1055 const_iterator
1056 upper_bound(const key_type& __x) const
1057 { return _M_t.upper_bound(__x); }
1058
1059#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
1060 template<typename _Kt>
1061 auto
1062 upper_bound(const _Kt& __x) const
1063 -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
1064 { return const_iterator(_M_t._M_upper_bound_tr(__x)); }
1065#endif
1066 ///@}
1067
1068 ///@{
1069 /**
1070 * @brief Finds a subsequence matching given key.
1071 * @param __x Key of (key, value) pairs to be located.
1072 * @return Pair of iterators that possibly points to the subsequence
1073 * matching given key.
1074 *
1075 * This function is equivalent to
1076 * @code
1077 * std::make_pair(c.lower_bound(val),
1078 * c.upper_bound(val))
1079 * @endcode
1080 * (but is faster than making the calls separately).
1081 */
1082 std::pair<iterator, iterator>
1083 equal_range(const key_type& __x)
1084 { return _M_t.equal_range(__x); }
1085
1086#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
1087 template<typename _Kt>
1088 auto
1089 equal_range(const _Kt& __x)
1090 -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)))
1091 { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); }
1092#endif
1093 ///@}
1094
1095 ///@{
1096 /**
1097 * @brief Finds a subsequence matching given key.
1098 * @param __x Key of (key, value) pairs to be located.
1099 * @return Pair of read-only (constant) iterators that possibly points
1100 * to the subsequence matching given key.
1101 *
1102 * This function is equivalent to
1103 * @code
1104 * std::make_pair(c.lower_bound(val),
1105 * c.upper_bound(val))
1106 * @endcode
1107 * (but is faster than making the calls separately).
1108 */
1109 std::pair<const_iterator, const_iterator>
1110 equal_range(const key_type& __x) const
1111 { return _M_t.equal_range(__x); }
1112
1113#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
1114 template<typename _Kt>
1115 auto
1116 equal_range(const _Kt& __x) const
1117 -> decltype(pair<const_iterator, const_iterator>(
1118 _M_t._M_equal_range_tr(__x)))
1119 {
1120 return pair<const_iterator, const_iterator>(
1121 _M_t._M_equal_range_tr(__x));
1122 }
1123#endif
1124 ///@}
1125
1126 template<typename _K1, typename _T1, typename _C1, typename _A1>
1127 friend bool
1128 operator==(const multimap<_K1, _T1, _C1, _A1>&,
1129 const multimap<_K1, _T1, _C1, _A1>&);
1130
1131#if __cpp_lib_three_way_comparison
1132 template<typename _K1, typename _T1, typename _C1, typename _A1>
1133 friend __detail::__synth3way_t<pair<const _K1, _T1>>
1134 operator<=>(const multimap<_K1, _T1, _C1, _A1>&,
1135 const multimap<_K1, _T1, _C1, _A1>&);
1136#else
1137 template<typename _K1, typename _T1, typename _C1, typename _A1>
1138 friend bool
1139 operator<(const multimap<_K1, _T1, _C1, _A1>&,
1140 const multimap<_K1, _T1, _C1, _A1>&);
1141#endif
1142 };
1143
1144#if __cpp_deduction_guides >= 201606
1145
1146 template<typename _InputIterator,
1147 typename _Compare = less<__iter_key_t<_InputIterator>>,
1148 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1149 typename = _RequireInputIter<_InputIterator>,
1150 typename = _RequireNotAllocator<_Compare>,
1151 typename = _RequireAllocator<_Allocator>>
1152 multimap(_InputIterator, _InputIterator,
1153 _Compare = _Compare(), _Allocator = _Allocator())
1154 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
1155 _Compare, _Allocator>;
1156
1157 template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
1158 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1159 typename = _RequireNotAllocator<_Compare>,
1160 typename = _RequireAllocator<_Allocator>>
1161 multimap(initializer_list<pair<_Key, _Tp>>,
1162 _Compare = _Compare(), _Allocator = _Allocator())
1163 -> multimap<_Key, _Tp, _Compare, _Allocator>;
1164
1165 template<typename _InputIterator, typename _Allocator,
1166 typename = _RequireInputIter<_InputIterator>,
1167 typename = _RequireAllocator<_Allocator>>
1168 multimap(_InputIterator, _InputIterator, _Allocator)
1169 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
1170 less<__iter_key_t<_InputIterator>>, _Allocator>;
1171
1172 template<typename _Key, typename _Tp, typename _Allocator,
1173 typename = _RequireAllocator<_Allocator>>
1174 multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
1175 -> multimap<_Key, _Tp, less<_Key>, _Allocator>;
1176
1177#if __glibcxx_containers_ranges // C++ >= 23
1178 template<ranges::input_range _Rg,
1179 __not_allocator_like _Compare = less<__detail::__range_key_type<_Rg>>,
1180 __allocator_like _Alloc =
1181 std::allocator<__detail::__range_to_alloc_type<_Rg>>>
1182 multimap(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
1183 -> multimap<__detail::__range_key_type<_Rg>,
1184 __detail::__range_mapped_type<_Rg>,
1185 _Compare, _Alloc>;
1186
1187 template<ranges::input_range _Rg, __allocator_like _Alloc>
1188 multimap(from_range_t, _Rg&&, _Alloc)
1189 -> multimap<__detail::__range_key_type<_Rg>,
1190 __detail::__range_mapped_type<_Rg>,
1191 less<__detail::__range_key_type<_Rg>>,
1192 _Alloc>;
1193#endif
1194
1195#endif // deduction guides
1196
1197 /**
1198 * @brief Multimap equality comparison.
1199 * @param __x A %multimap.
1200 * @param __y A %multimap of the same type as @a __x.
1201 * @return True iff the size and elements of the maps are equal.
1202 *
1203 * This is an equivalence relation. It is linear in the size of the
1204 * multimaps. Multimaps are considered equivalent if their sizes are equal,
1205 * and if corresponding elements compare equal.
1206 */
1207 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1208 inline bool
1209 operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1210 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1211 { return __x._M_t == __y._M_t; }
1212
1213#if __cpp_lib_three_way_comparison
1214 /**
1215 * @brief Multimap ordering relation.
1216 * @param __x A `multimap`.
1217 * @param __y A `multimap` of the same type as `x`.
1218 * @return A value indicating whether `__x` is less than, equal to,
1219 * greater than, or incomparable with `__y`.
1220 *
1221 * This is a total ordering relation. It is linear in the size of the
1222 * maps. The elements must be comparable with @c <.
1223 *
1224 * See `std::lexicographical_compare_three_way()` for how the determination
1225 * is made. This operator is used to synthesize relational operators like
1226 * `<` and `>=` etc.
1227 */
1228 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1229 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
1230 operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1231 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1232 { return __x._M_t <=> __y._M_t; }
1233#else
1234 /**
1235 * @brief Multimap ordering relation.
1236 * @param __x A %multimap.
1237 * @param __y A %multimap of the same type as @a __x.
1238 * @return True iff @a x is lexicographically less than @a y.
1239 *
1240 * This is a total ordering relation. It is linear in the size of the
1241 * multimaps. The elements must be comparable with @c <.
1242 *
1243 * See std::lexicographical_compare() for how the determination is made.
1244 */
1245 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1246 inline bool
1247 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1248 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1249 { return __x._M_t < __y._M_t; }
1250
1251 /// Based on operator==
1252 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1253 inline bool
1254 operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1255 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1256 { return !(__x == __y); }
1257
1258 /// Based on operator<
1259 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1260 inline bool
1261 operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1262 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1263 { return __y < __x; }
1264
1265 /// Based on operator<
1266 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1267 inline bool
1268 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1269 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1270 { return !(__y < __x); }
1271
1272 /// Based on operator<
1273 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1274 inline bool
1275 operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1276 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1277 { return !(__x < __y); }
1278#endif // three-way comparison
1279
1280 /// See std::multimap::swap().
1281 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
1282 inline void
1283 swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
1284 multimap<_Key, _Tp, _Compare, _Alloc>& __y)
1285 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1286 { __x.swap(__y); }
1287
1288_GLIBCXX_END_NAMESPACE_CONTAINER
1289
1290#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
1291 // Allow std::multimap access to internals of compatible maps.
1292 template<typename _Key, typename _Val, typename _Cmp1, typename _Alloc,
1293 typename _Cmp2>
1294 struct
1295 _Rb_tree_merge_helper<_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>,
1296 _Cmp2>
1297 {
1298 private:
1299 friend class _GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>;
1300
1301 static auto&
1302 _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
1303 { return __map._M_t; }
1304
1305 static auto&
1306 _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
1307 { return __map._M_t; }
1308 };
1309#endif // C++17
1310
1311_GLIBCXX_END_NAMESPACE_VERSION
1312} // namespace std
1313
1314#endif /* _STL_MULTIMAP_H */
initializer_list
concept_check.h
ranges_base.h
std::pair::pair
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
std::move
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Definition move.h:138
std::forward
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Definition move.h:72
std
ISO C++ entities toplevel namespace is std.
std::initializer_list
initializer_list
Definition initializer_list:53
std::is_same
is_same
Definition type_traits:1649
std::is_nothrow_copy_constructible
is_nothrow_copy_constructible
Definition type_traits:1361
std::size_type
std::allocator
The standard allocator, as per C++03 [20.4.1].
Definition allocator.h:134
std::binary_function
Definition stl_function.h:135
std::less
One of the comparison functors.
Definition stl_function.h:404
std::reverse_iterator
Definition bits/stl_iterator.h:137
std::pair
Struct holding two objects (or references) of arbitrary type.
Definition stl_pair.h:307
std::pair::first
_T1 first
The first member.
Definition stl_pair.h:311
std::iterator
Common iterator class.
Definition stl_iterator_base_types.h:133
std::multimap
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
Definition stl_multimap.h:106
std::multimap::insert
void insert(initializer_list< value_type > __l)
Attempts to insert a list of std::pairs into the multimap.
Definition stl_multimap.h:655
std::multimap::multimap
multimap(const allocator_type &__a)
Allocator-extended default constructor.
Definition stl_multimap.h:242
std::multimap::erase
size_type erase(const key_type &__x)
Erases elements according to the provided key.
Definition stl_multimap.h:795
std::multimap::emplace
iterator emplace(_Args &&... __args)
Build and insert a std::pair into the multimap.
Definition stl_multimap.h:521
std::multimap::multimap
multimap(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a multimap with no elements.
Definition stl_multimap.h:200
std::multimap::insert
iterator insert(const_iterator __position, value_type &&__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:619
std::multimap::operator=
multimap & operator=(const multimap &)=default
Multimap assignment operator.
std::multimap::empty
bool empty() const noexcept
Definition stl_multimap.h:488
std::multimap::find
const_iterator find(const key_type &__x) const
Tries to locate an element in a multimap.
Definition stl_multimap.h:930
std::multimap::operator=
multimap & operator=(initializer_list< value_type > __l)
Multimap list assignment operator.
Definition stl_multimap.h:362
std::multimap::begin
iterator begin() noexcept
Definition stl_multimap.h:381
std::multimap::clear
void clear() noexcept
Definition stl_multimap.h:871
std::multimap::insert
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
Definition stl_multimap.h:643
std::multimap::find
iterator find(const key_type &__x)
Tries to locate an element in a multimap.
Definition stl_multimap.h:906
std::multimap::end
const_iterator end() const noexcept
Definition stl_multimap.h:408
std::multimap::erase
iterator erase(const_iterator __position)
Erases an element from a multimap.
Definition stl_multimap.h:758
std::multimap::insert
__enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert(const_iterator __position, _Pair &&__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:624
std::multimap::rend
const_reverse_iterator rend() const noexcept
Definition stl_multimap.h:444
std::multimap::~multimap
~multimap()=default
std::multimap::multimap
multimap(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
Definition stl_multimap.h:263
std::multimap::crend
const_reverse_iterator crend() const noexcept
Definition stl_multimap.h:481
std::multimap::erase
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a multimap.
Definition stl_multimap.h:823
std::multimap::multimap
multimap(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a multimap from an initializer_list.
Definition stl_multimap.h:234
std::multimap::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
Definition stl_multimap.h:1110
std::multimap::swap
void swap(multimap &__x) noexcept(/*conditional */)
Swaps data with another multimap.
Definition stl_multimap.h:860
std::multimap::max_size
size_type max_size() const noexcept
Definition stl_multimap.h:498
std::multimap::rbegin
const_reverse_iterator rbegin() const noexcept
Definition stl_multimap.h:426
std::multimap::multimap
multimap(multimap &&__m, const __type_identity_t< allocator_type > &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
Definition stl_multimap.h:251
std::multimap::cbegin
const_iterator cbegin() const noexcept
Definition stl_multimap.h:454
std::multimap::multimap
multimap(const multimap &)=default
Multimap copy constructor.
std::multimap::key_comp
key_compare key_comp() const
Definition stl_multimap.h:880
std::multimap::insert
iterator insert(value_type &&__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:576
std::multimap::rend
reverse_iterator rend() noexcept
Definition stl_multimap.h:435
std::multimap::emplace_hint
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Builds and inserts a std::pair into the multimap.
Definition stl_multimap.h:548
std::multimap::contains
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
Definition stl_multimap.h:967
std::multimap::size
size_type size() const noexcept
Definition stl_multimap.h:493
std::multimap::get_allocator
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
Definition stl_multimap.h:371
std::multimap::crbegin
const_reverse_iterator crbegin() const noexcept
Definition stl_multimap.h:472
std::multimap::contains
auto contains(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
Definition stl_multimap.h:972
std::multimap::multimap
multimap(const multimap &__m, const __type_identity_t< allocator_type > &__a)
Allocator-extended copy constructor.
Definition stl_multimap.h:246
std::multimap::multimap
multimap(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initializer-list constructor.
Definition stl_multimap.h:257
std::multimap::cend
const_iterator cend() const noexcept
Definition stl_multimap.h:463
std::multimap::multimap
multimap(_InputIterator __first, _InputIterator __last)
Builds a multimap from a range.
Definition stl_multimap.h:279
std::multimap::upper_bound
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
Definition stl_multimap.h:1036
std::multimap::rbegin
reverse_iterator rbegin() noexcept
Definition stl_multimap.h:417
std::multimap::insert
iterator insert(const value_type &__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:569
std::multimap::begin
const_iterator begin() const noexcept
Definition stl_multimap.h:390
std::multimap::operator=
multimap & operator=(multimap &&)=default
Move assignment operator.
std::multimap::multimap
multimap(multimap &&)=default
Multimap move constructor.
std::multimap::multimap
multimap()=default
Default constructor creates no elements.
std::multimap::multimap
multimap(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a multimap from a range.
Definition stl_multimap.h:295
std::multimap::lower_bound
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
Definition stl_multimap.h:1016
std::multimap::value_comp
value_compare value_comp() const
Definition stl_multimap.h:888
std::multimap::lower_bound
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
Definition stl_multimap.h:991
std::multimap::insert
__enable_if_t< is_constructible< value_type, _Pair >::value, iterator > insert(_Pair &&__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:581
std::multimap::end
iterator end() noexcept
Definition stl_multimap.h:399
std::multimap::insert
iterator insert(const_iterator __position, const value_type &__x)
Inserts a std::pair into the multimap.
Definition stl_multimap.h:609
std::multimap::upper_bound
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
Definition stl_multimap.h:1056
std::multimap::count
size_type count(const key_type &__x) const
Finds the number of elements with given key.
Definition stl_multimap.h:948
std::multimap::erase
iterator erase(iterator __position)
Erases an element from a multimap.
Definition stl_multimap.h:764
std::multimap::equal_range
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
Definition stl_multimap.h:1083
std::map
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
Definition stl_map.h:107
__gnu_cxx::__alloc_traits
Uniform interface to C++98 and C++11 allocators.
Definition ext/alloc_traits.h:51
std::ranges::input_range
A range for which ranges::begin returns an input iterator.
Definition ranges_base.h:619