1 // Multiset implementation -*- C++ -*-
3 // Copyright (C) 2001-2015 Free Software Foundation, Inc.
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)
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.
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.
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/>.
28 * Hewlett-Packard Company
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.
40 * Silicon Graphics Computer Systems, Inc.
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.
51 /** @file bits/stl_multiset.h
52 * This is an internal header file, included by other library headers.
53 * Do not attempt to use it directly. @headername{set}
56 #ifndef _STL_MULTISET_H
57 #define _STL_MULTISET_H 1
59 #include <bits/concept_check.h>
60 #if __cplusplus >= 201103L
61 #include <initializer_list>
64 namespace std
_GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
69 * @brief A standard container made up of elements, which can be retrieved
70 * in logarithmic time.
72 * @ingroup associative_containers
75 * @tparam _Key Type of key objects.
76 * @tparam _Compare Comparison function object type, defaults to less<_Key>.
77 * @tparam _Alloc Allocator type, defaults to allocator<_Key>.
79 * Meets the requirements of a <a href="tables.html#65">container</a>, a
80 * <a href="tables.html#66">reversible container</a>, and an
81 * <a href="tables.html#69">associative container</a> (using equivalent
82 * keys). For a @c multiset<Key> the key_type and value_type are Key.
84 * Multisets support bidirectional iterators.
86 * The private tree data is declared exactly the same way for set and
87 * multiset; the distinction is made entirely in how the tree functions are
88 * called (*_unique versus *_equal, same as the standard).
90 template <typename _Key
, typename _Compare
= std::less
<_Key
>,
91 typename _Alloc
= std::allocator
<_Key
> >
94 // concept requirements
95 typedef typename
_Alloc::value_type _Alloc_value_type
;
96 __glibcxx_class_requires(_Key
, _SGIAssignableConcept
)
97 __glibcxx_class_requires4(_Compare
, bool, _Key
, _Key
,
98 _BinaryFunctionConcept
)
99 __glibcxx_class_requires2(_Key
, _Alloc_value_type
, _SameTypeConcept
)
103 typedef _Key key_type
;
104 typedef _Key value_type
;
105 typedef _Compare key_compare
;
106 typedef _Compare value_compare
;
107 typedef _Alloc allocator_type
;
110 /// This turns a red-black tree into a [multi]set.
111 typedef typename
__gnu_cxx::__alloc_traits
<_Alloc
>::template
112 rebind
<_Key
>::other _Key_alloc_type
;
114 typedef _Rb_tree
<key_type
, value_type
, _Identity
<value_type
>,
115 key_compare
, _Key_alloc_type
> _Rep_type
;
116 /// The actual tree structure.
119 typedef __gnu_cxx::__alloc_traits
<_Key_alloc_type
> _Alloc_traits
;
122 typedef typename
_Alloc_traits::pointer pointer
;
123 typedef typename
_Alloc_traits::const_pointer const_pointer
;
124 typedef typename
_Alloc_traits::reference reference
;
125 typedef typename
_Alloc_traits::const_reference const_reference
;
126 // _GLIBCXX_RESOLVE_LIB_DEFECTS
127 // DR 103. set::iterator is required to be modifiable,
128 // but this allows modification of keys.
129 typedef typename
_Rep_type::const_iterator iterator
;
130 typedef typename
_Rep_type::const_iterator const_iterator
;
131 typedef typename
_Rep_type::const_reverse_iterator reverse_iterator
;
132 typedef typename
_Rep_type::const_reverse_iterator const_reverse_iterator
;
133 typedef typename
_Rep_type::size_type size_type
;
134 typedef typename
_Rep_type::difference_type difference_type
;
136 // allocation/deallocation
138 * @brief Default constructor creates no elements.
144 * @brief Creates a %multiset with no elements.
145 * @param __comp Comparator to use.
146 * @param __a An allocator object.
149 multiset(const _Compare
& __comp
,
150 const allocator_type
& __a
= allocator_type())
151 : _M_t(__comp
, _Key_alloc_type(__a
)) { }
154 * @brief Builds a %multiset from a range.
155 * @param __first An input iterator.
156 * @param __last An input iterator.
158 * Create a %multiset consisting of copies of the elements from
159 * [first,last). This is linear in N if the range is already sorted,
160 * and NlogN otherwise (where N is distance(__first,__last)).
162 template<typename _InputIterator
>
163 multiset(_InputIterator __first
, _InputIterator __last
)
165 { _M_t
._M_insert_equal(__first
, __last
); }
168 * @brief Builds a %multiset from a range.
169 * @param __first An input iterator.
170 * @param __last An input iterator.
171 * @param __comp A comparison functor.
172 * @param __a An allocator object.
174 * Create a %multiset consisting of copies of the elements from
175 * [__first,__last). This is linear in N if the range is already sorted,
176 * and NlogN otherwise (where N is distance(__first,__last)).
178 template<typename _InputIterator
>
179 multiset(_InputIterator __first
, _InputIterator __last
,
180 const _Compare
& __comp
,
181 const allocator_type
& __a
= allocator_type())
182 : _M_t(__comp
, _Key_alloc_type(__a
))
183 { _M_t
._M_insert_equal(__first
, __last
); }
186 * @brief %Multiset copy constructor.
187 * @param __x A %multiset of identical element and allocator types.
189 * The newly-created %multiset uses a copy of the allocation object used
192 multiset(const multiset
& __x
)
195 #if __cplusplus >= 201103L
197 * @brief %Multiset move constructor.
198 * @param __x A %multiset of identical element and allocator types.
200 * The newly-created %multiset contains the exact contents of @a __x.
201 * The contents of @a __x are a valid, but unspecified %multiset.
203 multiset(multiset
&& __x
)
204 noexcept(is_nothrow_copy_constructible
<_Compare
>::value
)
205 : _M_t(std::move(__x
._M_t
)) { }
208 * @brief Builds a %multiset from an initializer_list.
209 * @param __l An initializer_list.
210 * @param __comp A comparison functor.
211 * @param __a An allocator object.
213 * Create a %multiset consisting of copies of the elements from
214 * the list. This is linear in N if the list is already sorted,
215 * and NlogN otherwise (where N is @a __l.size()).
217 multiset(initializer_list
<value_type
> __l
,
218 const _Compare
& __comp
= _Compare(),
219 const allocator_type
& __a
= allocator_type())
220 : _M_t(__comp
, _Key_alloc_type(__a
))
221 { _M_t
._M_insert_equal(__l
.begin(), __l
.end()); }
223 /// Allocator-extended default constructor.
225 multiset(const allocator_type
& __a
)
226 : _M_t(_Compare(), _Key_alloc_type(__a
)) { }
228 /// Allocator-extended copy constructor.
229 multiset(const multiset
& __m
, const allocator_type
& __a
)
230 : _M_t(__m
._M_t
, _Key_alloc_type(__a
)) { }
232 /// Allocator-extended move constructor.
233 multiset(multiset
&& __m
, const allocator_type
& __a
)
234 noexcept(is_nothrow_copy_constructible
<_Compare
>::value
235 && _Alloc_traits::_S_always_equal())
236 : _M_t(std::move(__m
._M_t
), _Key_alloc_type(__a
)) { }
238 /// Allocator-extended initialier-list constructor.
239 multiset(initializer_list
<value_type
> __l
, const allocator_type
& __a
)
240 : _M_t(_Compare(), _Key_alloc_type(__a
))
241 { _M_t
._M_insert_equal(__l
.begin(), __l
.end()); }
243 /// Allocator-extended range constructor.
244 template<typename _InputIterator
>
245 multiset(_InputIterator __first
, _InputIterator __last
,
246 const allocator_type
& __a
)
247 : _M_t(_Compare(), _Key_alloc_type(__a
))
248 { _M_t
._M_insert_equal(__first
, __last
); }
252 * @brief %Multiset assignment operator.
253 * @param __x A %multiset of identical element and allocator types.
255 * All the elements of @a __x are copied, but unlike the copy
256 * constructor, the allocator object is not copied.
259 operator=(const multiset
& __x
)
265 #if __cplusplus >= 201103L
266 /// Move assignment operator.
268 operator=(multiset
&&) = default;
271 * @brief %Multiset list assignment operator.
272 * @param __l An initializer_list.
274 * This function fills a %multiset with copies of the elements in the
275 * initializer list @a __l.
277 * Note that the assignment completely changes the %multiset and
278 * that the resulting %multiset's size is the same as the number
279 * of elements assigned. Old data may be lost.
282 operator=(initializer_list
<value_type
> __l
)
284 _M_t
._M_assign_equal(__l
.begin(), __l
.end());
291 /// Returns the comparison object.
294 { return _M_t
.key_comp(); }
295 /// Returns the comparison object.
298 { return _M_t
.key_comp(); }
299 /// Returns the memory allocation object.
301 get_allocator() const _GLIBCXX_NOEXCEPT
302 { return allocator_type(_M_t
.get_allocator()); }
305 * Returns a read-only (constant) iterator that points to the first
306 * element in the %multiset. Iteration is done in ascending order
307 * according to the keys.
310 begin() const _GLIBCXX_NOEXCEPT
311 { return _M_t
.begin(); }
314 * Returns a read-only (constant) iterator that points one past the last
315 * element in the %multiset. Iteration is done in ascending order
316 * according to the keys.
319 end() const _GLIBCXX_NOEXCEPT
320 { return _M_t
.end(); }
323 * Returns a read-only (constant) reverse iterator that points to the
324 * last element in the %multiset. Iteration is done in descending order
325 * according to the keys.
328 rbegin() const _GLIBCXX_NOEXCEPT
329 { return _M_t
.rbegin(); }
332 * Returns a read-only (constant) reverse iterator that points to the
333 * last element in the %multiset. Iteration is done in descending order
334 * according to the keys.
337 rend() const _GLIBCXX_NOEXCEPT
338 { return _M_t
.rend(); }
340 #if __cplusplus >= 201103L
342 * Returns a read-only (constant) iterator that points to the first
343 * element in the %multiset. Iteration is done in ascending order
344 * according to the keys.
347 cbegin() const noexcept
348 { return _M_t
.begin(); }
351 * Returns a read-only (constant) iterator that points one past the last
352 * element in the %multiset. Iteration is done in ascending order
353 * according to the keys.
356 cend() const noexcept
357 { return _M_t
.end(); }
360 * Returns a read-only (constant) reverse iterator that points to the
361 * last element in the %multiset. Iteration is done in descending order
362 * according to the keys.
365 crbegin() const noexcept
366 { return _M_t
.rbegin(); }
369 * Returns a read-only (constant) reverse iterator that points to the
370 * last element in the %multiset. Iteration is done in descending order
371 * according to the keys.
374 crend() const noexcept
375 { return _M_t
.rend(); }
378 /// Returns true if the %set is empty.
380 empty() const _GLIBCXX_NOEXCEPT
381 { return _M_t
.empty(); }
383 /// Returns the size of the %set.
385 size() const _GLIBCXX_NOEXCEPT
386 { return _M_t
.size(); }
388 /// Returns the maximum size of the %set.
390 max_size() const _GLIBCXX_NOEXCEPT
391 { return _M_t
.max_size(); }
394 * @brief Swaps data with another %multiset.
395 * @param __x A %multiset of the same element and allocator types.
397 * This exchanges the elements between two multisets in constant time.
398 * (It is only swapping a pointer, an integer, and an instance of the @c
399 * Compare type (which itself is often stateless and empty), so it should
401 * Note that the global std::swap() function is specialized such that
402 * std::swap(s1,s2) will feed to this function.
406 #if __cplusplus >= 201103L
407 noexcept(_Alloc_traits::_S_nothrow_swap())
409 { _M_t
.swap(__x
._M_t
); }
412 #if __cplusplus >= 201103L
414 * @brief Builds and inserts an element into the %multiset.
415 * @param __args Arguments used to generate the element instance to be
417 * @return An iterator that points to the inserted element.
419 * This function inserts an element into the %multiset. Contrary
420 * to a std::set the %multiset does not rely on unique keys and thus
421 * multiple copies of the same element can be inserted.
423 * Insertion requires logarithmic time.
425 template<typename
... _Args
>
427 emplace(_Args
&&... __args
)
428 { return _M_t
._M_emplace_equal(std::forward
<_Args
>(__args
)...); }
431 * @brief Builds and inserts an element into the %multiset.
432 * @param __pos An iterator that serves as a hint as to where the
433 * element should be inserted.
434 * @param __args Arguments used to generate the element instance to be
436 * @return An iterator that points to the inserted element.
438 * This function inserts an element into the %multiset. Contrary
439 * to a std::set the %multiset does not rely on unique keys and thus
440 * multiple copies of the same element can be inserted.
442 * Note that the first parameter is only a hint and can potentially
443 * improve the performance of the insertion process. A bad hint would
444 * cause no gains in efficiency.
446 * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
447 * for more on @a hinting.
449 * Insertion requires logarithmic time (if the hint is not taken).
451 template<typename
... _Args
>
453 emplace_hint(const_iterator __pos
, _Args
&&... __args
)
455 return _M_t
._M_emplace_hint_equal(__pos
,
456 std::forward
<_Args
>(__args
)...);
461 * @brief Inserts an element into the %multiset.
462 * @param __x Element to be inserted.
463 * @return An iterator that points to the inserted element.
465 * This function inserts an element into the %multiset. Contrary
466 * to a std::set the %multiset does not rely on unique keys and thus
467 * multiple copies of the same element can be inserted.
469 * Insertion requires logarithmic time.
472 insert(const value_type
& __x
)
473 { return _M_t
._M_insert_equal(__x
); }
475 #if __cplusplus >= 201103L
477 insert(value_type
&& __x
)
478 { return _M_t
._M_insert_equal(std::move(__x
)); }
482 * @brief Inserts an element into the %multiset.
483 * @param __position An iterator that serves as a hint as to where the
484 * element should be inserted.
485 * @param __x Element to be inserted.
486 * @return An iterator that points to the inserted element.
488 * This function inserts an element into the %multiset. Contrary
489 * to a std::set the %multiset does not rely on unique keys and thus
490 * multiple copies of the same element can be inserted.
492 * Note that the first parameter is only a hint and can potentially
493 * improve the performance of the insertion process. A bad hint would
494 * cause no gains in efficiency.
496 * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
497 * for more on @a hinting.
499 * Insertion requires logarithmic time (if the hint is not taken).
502 insert(const_iterator __position
, const value_type
& __x
)
503 { return _M_t
._M_insert_equal_(__position
, __x
); }
505 #if __cplusplus >= 201103L
507 insert(const_iterator __position
, value_type
&& __x
)
508 { return _M_t
._M_insert_equal_(__position
, std::move(__x
)); }
512 * @brief A template function that tries to insert a range of elements.
513 * @param __first Iterator pointing to the start of the range to be
515 * @param __last Iterator pointing to the end of the range.
517 * Complexity similar to that of the range constructor.
519 template<typename _InputIterator
>
521 insert(_InputIterator __first
, _InputIterator __last
)
522 { _M_t
._M_insert_equal(__first
, __last
); }
524 #if __cplusplus >= 201103L
526 * @brief Attempts to insert a list of elements into the %multiset.
527 * @param __l A std::initializer_list<value_type> of elements
530 * Complexity similar to that of the range constructor.
533 insert(initializer_list
<value_type
> __l
)
534 { this->insert(__l
.begin(), __l
.end()); }
537 #if __cplusplus >= 201103L
538 // _GLIBCXX_RESOLVE_LIB_DEFECTS
539 // DR 130. Associative erase should return an iterator.
541 * @brief Erases an element from a %multiset.
542 * @param __position An iterator pointing to the element to be erased.
543 * @return An iterator pointing to the element immediately following
544 * @a position prior to the element being erased. If no such
545 * element exists, end() is returned.
547 * This function erases an element, pointed to by the given iterator,
548 * from a %multiset. Note that this function only erases the element,
549 * and that if the element is itself a pointer, the pointed-to memory is
550 * not touched in any way. Managing the pointer is the user's
553 _GLIBCXX_ABI_TAG_CXX11
555 erase(const_iterator __position
)
556 { return _M_t
.erase(__position
); }
559 * @brief Erases an element from a %multiset.
560 * @param __position An iterator pointing to the element to be erased.
562 * This function erases an element, pointed to by the given iterator,
563 * from a %multiset. Note that this function only erases the element,
564 * and that if the element is itself a pointer, the pointed-to memory is
565 * not touched in any way. Managing the pointer is the user's
569 erase(iterator __position
)
570 { _M_t
.erase(__position
); }
574 * @brief Erases elements according to the provided key.
575 * @param __x Key of element to be erased.
576 * @return The number of elements erased.
578 * This function erases all elements located by the given key from a
580 * Note that this function only erases the element, and that if
581 * the element is itself a pointer, the pointed-to memory is not touched
582 * in any way. Managing the pointer is the user's responsibility.
585 erase(const key_type
& __x
)
586 { return _M_t
.erase(__x
); }
588 #if __cplusplus >= 201103L
589 // _GLIBCXX_RESOLVE_LIB_DEFECTS
590 // DR 130. Associative erase should return an iterator.
592 * @brief Erases a [first,last) range of elements from a %multiset.
593 * @param __first Iterator pointing to the start of the range to be
595 * @param __last Iterator pointing to the end of the range to
597 * @return The iterator @a last.
599 * This function erases a sequence of elements from a %multiset.
600 * Note that this function only erases the elements, and that if
601 * the elements themselves are pointers, the pointed-to memory is not
602 * touched in any way. Managing the pointer is the user's
605 _GLIBCXX_ABI_TAG_CXX11
607 erase(const_iterator __first
, const_iterator __last
)
608 { return _M_t
.erase(__first
, __last
); }
611 * @brief Erases a [first,last) range of elements from a %multiset.
612 * @param first Iterator pointing to the start of the range to be
614 * @param last Iterator pointing to the end of the range to be erased.
616 * This function erases a sequence of elements from a %multiset.
617 * Note that this function only erases the elements, and that if
618 * the elements themselves are pointers, the pointed-to memory is not
619 * touched in any way. Managing the pointer is the user's
623 erase(iterator __first
, iterator __last
)
624 { _M_t
.erase(__first
, __last
); }
628 * Erases all elements in a %multiset. Note that this function only
629 * erases the elements, and that if the elements themselves are pointers,
630 * the pointed-to memory is not touched in any way. Managing the pointer
631 * is the user's responsibility.
634 clear() _GLIBCXX_NOEXCEPT
637 // multiset operations:
641 * @brief Finds the number of elements with given key.
642 * @param __x Key of elements to be located.
643 * @return Number of elements with specified key.
646 count(const key_type
& __x
) const
647 { return _M_t
.count(__x
); }
649 #if __cplusplus > 201103L
650 template<typename _Kt
>
652 count(const _Kt
& __x
) const -> decltype(_M_t
._M_count_tr(__x
))
653 { return _M_t
._M_count_tr(__x
); }
657 // _GLIBCXX_RESOLVE_LIB_DEFECTS
658 // 214. set::find() missing const overload
661 * @brief Tries to locate an element in a %set.
662 * @param __x Element to be located.
663 * @return Iterator pointing to sought-after element, or end() if not
666 * This function takes a key and tries to locate the element with which
667 * the key matches. If successful the function returns an iterator
668 * pointing to the sought after element. If unsuccessful it returns the
669 * past-the-end ( @c end() ) iterator.
672 find(const key_type
& __x
)
673 { return _M_t
.find(__x
); }
676 find(const key_type
& __x
) const
677 { return _M_t
.find(__x
); }
679 #if __cplusplus > 201103L
680 template<typename _Kt
>
682 find(const _Kt
& __x
) -> decltype(_M_t
._M_find_tr(__x
))
683 { return _M_t
._M_find_tr(__x
); }
685 template<typename _Kt
>
687 find(const _Kt
& __x
) const -> decltype(_M_t
._M_find_tr(__x
))
688 { return _M_t
._M_find_tr(__x
); }
694 * @brief Finds the beginning of a subsequence matching given key.
695 * @param __x Key to be located.
696 * @return Iterator pointing to first element equal to or greater
697 * than key, or end().
699 * This function returns the first element of a subsequence of elements
700 * that matches the given key. If unsuccessful it returns an iterator
701 * pointing to the first element that has a greater value than given key
702 * or end() if no such element exists.
705 lower_bound(const key_type
& __x
)
706 { return _M_t
.lower_bound(__x
); }
709 lower_bound(const key_type
& __x
) const
710 { return _M_t
.lower_bound(__x
); }
712 #if __cplusplus > 201103L
713 template<typename _Kt
>
715 lower_bound(const _Kt
& __x
)
716 -> decltype(_M_t
._M_lower_bound_tr(__x
))
717 { return _M_t
._M_lower_bound_tr(__x
); }
719 template<typename _Kt
>
721 lower_bound(const _Kt
& __x
) const
722 -> decltype(_M_t
._M_lower_bound_tr(__x
))
723 { return _M_t
._M_lower_bound_tr(__x
); }
729 * @brief Finds the end of a subsequence matching given key.
730 * @param __x Key to be located.
731 * @return Iterator pointing to the first element
732 * greater than key, or end().
735 upper_bound(const key_type
& __x
)
736 { return _M_t
.upper_bound(__x
); }
739 upper_bound(const key_type
& __x
) const
740 { return _M_t
.upper_bound(__x
); }
742 #if __cplusplus > 201103L
743 template<typename _Kt
>
745 upper_bound(const _Kt
& __x
)
746 -> decltype(_M_t
._M_upper_bound_tr(__x
))
747 { return _M_t
._M_upper_bound_tr(__x
); }
749 template<typename _Kt
>
751 upper_bound(const _Kt
& __x
) const
752 -> decltype(_M_t
._M_upper_bound_tr(__x
))
753 { return _M_t
._M_upper_bound_tr(__x
); }
759 * @brief Finds a subsequence matching given key.
760 * @param __x Key to be located.
761 * @return Pair of iterators that possibly points to the subsequence
762 * matching given key.
764 * This function is equivalent to
766 * std::make_pair(c.lower_bound(val),
767 * c.upper_bound(val))
769 * (but is faster than making the calls separately).
771 * This function probably only makes sense for multisets.
773 std::pair
<iterator
, iterator
>
774 equal_range(const key_type
& __x
)
775 { return _M_t
.equal_range(__x
); }
777 std::pair
<const_iterator
, const_iterator
>
778 equal_range(const key_type
& __x
) const
779 { return _M_t
.equal_range(__x
); }
781 #if __cplusplus > 201103L
782 template<typename _Kt
>
784 equal_range(const _Kt
& __x
)
785 -> decltype(_M_t
._M_equal_range_tr(__x
))
786 { return _M_t
._M_equal_range_tr(__x
); }
788 template<typename _Kt
>
790 equal_range(const _Kt
& __x
) const
791 -> decltype(_M_t
._M_equal_range_tr(__x
))
792 { return _M_t
._M_equal_range_tr(__x
); }
796 template<typename _K1
, typename _C1
, typename _A1
>
798 operator==(const multiset
<_K1
, _C1
, _A1
>&,
799 const multiset
<_K1
, _C1
, _A1
>&);
801 template<typename _K1
, typename _C1
, typename _A1
>
803 operator< (const multiset
<_K1
, _C1
, _A1
>&,
804 const multiset
<_K1
, _C1
, _A1
>&);
808 * @brief Multiset equality comparison.
809 * @param __x A %multiset.
810 * @param __y A %multiset of the same type as @a __x.
811 * @return True iff the size and elements of the multisets are equal.
813 * This is an equivalence relation. It is linear in the size of the
815 * Multisets are considered equivalent if their sizes are equal, and if
816 * corresponding elements compare equal.
818 template<typename _Key
, typename _Compare
, typename _Alloc
>
820 operator==(const multiset
<_Key
, _Compare
, _Alloc
>& __x
,
821 const multiset
<_Key
, _Compare
, _Alloc
>& __y
)
822 { return __x
._M_t
== __y
._M_t
; }
825 * @brief Multiset ordering relation.
826 * @param __x A %multiset.
827 * @param __y A %multiset of the same type as @a __x.
828 * @return True iff @a __x is lexicographically less than @a __y.
830 * This is a total ordering relation. It is linear in the size of the
831 * sets. The elements must be comparable with @c <.
833 * See std::lexicographical_compare() for how the determination is made.
835 template<typename _Key
, typename _Compare
, typename _Alloc
>
837 operator<(const multiset
<_Key
, _Compare
, _Alloc
>& __x
,
838 const multiset
<_Key
, _Compare
, _Alloc
>& __y
)
839 { return __x
._M_t
< __y
._M_t
; }
841 /// Returns !(x == y).
842 template<typename _Key
, typename _Compare
, typename _Alloc
>
844 operator!=(const multiset
<_Key
, _Compare
, _Alloc
>& __x
,
845 const multiset
<_Key
, _Compare
, _Alloc
>& __y
)
846 { return !(__x
== __y
); }
849 template<typename _Key
, typename _Compare
, typename _Alloc
>
851 operator>(const multiset
<_Key
,_Compare
,_Alloc
>& __x
,
852 const multiset
<_Key
,_Compare
,_Alloc
>& __y
)
853 { return __y
< __x
; }
856 template<typename _Key
, typename _Compare
, typename _Alloc
>
858 operator<=(const multiset
<_Key
, _Compare
, _Alloc
>& __x
,
859 const multiset
<_Key
, _Compare
, _Alloc
>& __y
)
860 { return !(__y
< __x
); }
863 template<typename _Key
, typename _Compare
, typename _Alloc
>
865 operator>=(const multiset
<_Key
, _Compare
, _Alloc
>& __x
,
866 const multiset
<_Key
, _Compare
, _Alloc
>& __y
)
867 { return !(__x
< __y
); }
869 /// See std::multiset::swap().
870 template<typename _Key
, typename _Compare
, typename _Alloc
>
872 swap(multiset
<_Key
, _Compare
, _Alloc
>& __x
,
873 multiset
<_Key
, _Compare
, _Alloc
>& __y
)
876 _GLIBCXX_END_NAMESPACE_CONTAINER
879 #endif /* _STL_MULTISET_H */