Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / include / bits / stl_multimap.h
blobec0c9a080d62cb216ffccbdbc67e894ef68ceb5f
1 // Multimap implementation -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
28 * Copyright (c) 1994
29 * Hewlett-Packard Company
31 * Permission to use, copy, modify, distribute and sell this software
32 * and its documentation for any purpose is hereby granted without fee,
33 * provided that the above copyright notice appear in all copies and
34 * that both that copyright notice and this permission notice appear
35 * in supporting documentation. Hewlett-Packard Company makes no
36 * representations about the suitability of this software for any
37 * purpose. It is provided "as is" without express or implied warranty.
40 * Copyright (c) 1996,1997
41 * Silicon Graphics Computer Systems, Inc.
43 * Permission to use, copy, modify, distribute and sell this software
44 * and its documentation for any purpose is hereby granted without fee,
45 * provided that the above copyright notice appear in all copies and
46 * that both that copyright notice and this permission notice appear
47 * in supporting documentation. Silicon Graphics makes no
48 * representations about the suitability of this software for any
49 * purpose. It is provided "as is" without express or implied warranty.
52 /** @file stl_multimap.h
53 * This is an internal header file, included by other library headers.
54 * You should not attempt to use it directly.
57 #ifndef _STL_MULTIMAP_H
58 #define _STL_MULTIMAP_H 1
60 #include <bits/concept_check.h>
61 #include <initializer_list>
63 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
65 /**
66 * @brief A standard container made up of (key,value) pairs, which can be
67 * retrieved based on a key, in logarithmic time.
69 * @ingroup associative_containers
71 * Meets the requirements of a <a href="tables.html#65">container</a>, a
72 * <a href="tables.html#66">reversible container</a>, and an
73 * <a href="tables.html#69">associative container</a> (using equivalent
74 * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
75 * is T, and the value_type is std::pair<const Key,T>.
77 * Multimaps support bidirectional iterators.
79 * The private tree data is declared exactly the same way for map and
80 * multimap; the distinction is made entirely in how the tree functions are
81 * called (*_unique versus *_equal, same as the standard).
83 template <typename _Key, typename _Tp,
84 typename _Compare = std::less<_Key>,
85 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
86 class multimap
88 public:
89 typedef _Key key_type;
90 typedef _Tp mapped_type;
91 typedef std::pair<const _Key, _Tp> value_type;
92 typedef _Compare key_compare;
93 typedef _Alloc allocator_type;
95 private:
96 // concept requirements
97 typedef typename _Alloc::value_type _Alloc_value_type;
98 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
99 __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
100 _BinaryFunctionConcept)
101 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
103 public:
104 class value_compare
105 : public std::binary_function<value_type, value_type, bool>
107 friend class multimap<_Key, _Tp, _Compare, _Alloc>;
108 protected:
109 _Compare comp;
111 value_compare(_Compare __c)
112 : comp(__c) { }
114 public:
115 bool operator()(const value_type& __x, const value_type& __y) const
116 { return comp(__x.first, __y.first); }
119 private:
120 /// This turns a red-black tree into a [multi]map.
121 typedef typename _Alloc::template rebind<value_type>::other
122 _Pair_alloc_type;
124 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
125 key_compare, _Pair_alloc_type> _Rep_type;
126 /// The actual tree structure.
127 _Rep_type _M_t;
129 public:
130 // many of these are specified differently in ISO, but the following are
131 // "functionally equivalent"
132 typedef typename _Pair_alloc_type::pointer pointer;
133 typedef typename _Pair_alloc_type::const_pointer const_pointer;
134 typedef typename _Pair_alloc_type::reference reference;
135 typedef typename _Pair_alloc_type::const_reference const_reference;
136 typedef typename _Rep_type::iterator iterator;
137 typedef typename _Rep_type::const_iterator const_iterator;
138 typedef typename _Rep_type::size_type size_type;
139 typedef typename _Rep_type::difference_type difference_type;
140 typedef typename _Rep_type::reverse_iterator reverse_iterator;
141 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
143 // [23.3.2] construct/copy/destroy
144 // (get_allocator() is also listed in this section)
146 * @brief Default constructor creates no elements.
148 multimap()
149 : _M_t() { }
152 * @brief Creates a %multimap with no elements.
153 * @param comp A comparison object.
154 * @param a An allocator object.
156 explicit
157 multimap(const _Compare& __comp,
158 const allocator_type& __a = allocator_type())
159 : _M_t(__comp, __a) { }
162 * @brief %Multimap copy constructor.
163 * @param x A %multimap of identical element and allocator types.
165 * The newly-created %multimap uses a copy of the allocation object
166 * used by @a x.
168 multimap(const multimap& __x)
169 : _M_t(__x._M_t) { }
171 #ifdef __GXX_EXPERIMENTAL_CXX0X__
173 * @brief %Multimap move constructor.
174 * @param x A %multimap of identical element and allocator types.
176 * The newly-created %multimap contains the exact contents of @a x.
177 * The contents of @a x are a valid, but unspecified %multimap.
179 multimap(multimap&& __x)
180 : _M_t(std::move(__x._M_t)) { }
183 * @brief Builds a %multimap from an initializer_list.
184 * @param l An initializer_list.
185 * @param comp A comparison functor.
186 * @param a An allocator object.
188 * Create a %multimap consisting of copies of the elements from
189 * the initializer_list. This is linear in N if the list is already
190 * sorted, and NlogN otherwise (where N is @a __l.size()).
192 multimap(initializer_list<value_type> __l,
193 const _Compare& __comp = _Compare(),
194 const allocator_type& __a = allocator_type())
195 : _M_t(__comp, __a)
196 { _M_t._M_insert_equal(__l.begin(), __l.end()); }
197 #endif
200 * @brief Builds a %multimap from a range.
201 * @param first An input iterator.
202 * @param last An input iterator.
204 * Create a %multimap consisting of copies of the elements from
205 * [first,last). This is linear in N if the range is already sorted,
206 * and NlogN otherwise (where N is distance(first,last)).
208 template<typename _InputIterator>
209 multimap(_InputIterator __first, _InputIterator __last)
210 : _M_t()
211 { _M_t._M_insert_equal(__first, __last); }
214 * @brief Builds a %multimap from a range.
215 * @param first An input iterator.
216 * @param last An input iterator.
217 * @param comp A comparison functor.
218 * @param a An allocator object.
220 * Create a %multimap consisting of copies of the elements from
221 * [first,last). This is linear in N if the range is already sorted,
222 * and NlogN otherwise (where N is distance(first,last)).
224 template<typename _InputIterator>
225 multimap(_InputIterator __first, _InputIterator __last,
226 const _Compare& __comp,
227 const allocator_type& __a = allocator_type())
228 : _M_t(__comp, __a)
229 { _M_t._M_insert_equal(__first, __last); }
231 // FIXME There is no dtor declared, but we should have something generated
232 // by Doxygen. I don't know what tags to add to this paragraph to make
233 // that happen:
235 * The dtor only erases the elements, and note that if the elements
236 * themselves are pointers, the pointed-to memory is not touched in any
237 * way. Managing the pointer is the user's responsibility.
241 * @brief %Multimap assignment operator.
242 * @param x A %multimap of identical element and allocator types.
244 * All the elements of @a x are copied, but unlike the copy constructor,
245 * the allocator object is not copied.
247 multimap&
248 operator=(const multimap& __x)
250 _M_t = __x._M_t;
251 return *this;
254 #ifdef __GXX_EXPERIMENTAL_CXX0X__
256 * @brief %Multimap move assignment operator.
257 * @param x A %multimap of identical element and allocator types.
259 * The contents of @a x are moved into this multimap (without copying).
260 * @a x is a valid, but unspecified multimap.
262 multimap&
263 operator=(multimap&& __x)
265 // NB: DR 1204.
266 // NB: DR 675.
267 this->clear();
268 this->swap(__x);
269 return *this;
273 * @brief %Multimap list assignment operator.
274 * @param l An initializer_list.
276 * This function fills a %multimap with copies of the elements
277 * in the initializer list @a l.
279 * Note that the assignment completely changes the %multimap and
280 * that the resulting %multimap's size is the same as the number
281 * of elements assigned. Old data may be lost.
283 multimap&
284 operator=(initializer_list<value_type> __l)
286 this->clear();
287 this->insert(__l.begin(), __l.end());
288 return *this;
290 #endif
292 /// Get a copy of the memory allocation object.
293 allocator_type
294 get_allocator() const
295 { return _M_t.get_allocator(); }
297 // iterators
299 * Returns a read/write iterator that points to the first pair in the
300 * %multimap. Iteration is done in ascending order according to the
301 * keys.
303 iterator
304 begin()
305 { return _M_t.begin(); }
308 * Returns a read-only (constant) iterator that points to the first pair
309 * in the %multimap. Iteration is done in ascending order according to
310 * the keys.
312 const_iterator
313 begin() const
314 { return _M_t.begin(); }
317 * Returns a read/write iterator that points one past the last pair in
318 * the %multimap. Iteration is done in ascending order according to the
319 * keys.
321 iterator
322 end()
323 { return _M_t.end(); }
326 * Returns a read-only (constant) iterator that points one past the last
327 * pair in the %multimap. Iteration is done in ascending order according
328 * to the keys.
330 const_iterator
331 end() const
332 { return _M_t.end(); }
335 * Returns a read/write reverse iterator that points to the last pair in
336 * the %multimap. Iteration is done in descending order according to the
337 * keys.
339 reverse_iterator
340 rbegin()
341 { return _M_t.rbegin(); }
344 * Returns a read-only (constant) reverse iterator that points to the
345 * last pair in the %multimap. Iteration is done in descending order
346 * according to the keys.
348 const_reverse_iterator
349 rbegin() const
350 { return _M_t.rbegin(); }
353 * Returns a read/write reverse iterator that points to one before the
354 * first pair in the %multimap. Iteration is done in descending order
355 * according to the keys.
357 reverse_iterator
358 rend()
359 { return _M_t.rend(); }
362 * Returns a read-only (constant) reverse iterator that points to one
363 * before the first pair in the %multimap. Iteration is done in
364 * descending order according to the keys.
366 const_reverse_iterator
367 rend() const
368 { return _M_t.rend(); }
370 #ifdef __GXX_EXPERIMENTAL_CXX0X__
372 * Returns a read-only (constant) iterator that points to the first pair
373 * in the %multimap. Iteration is done in ascending order according to
374 * the keys.
376 const_iterator
377 cbegin() const
378 { return _M_t.begin(); }
381 * Returns a read-only (constant) iterator that points one past the last
382 * pair in the %multimap. Iteration is done in ascending order according
383 * to the keys.
385 const_iterator
386 cend() const
387 { return _M_t.end(); }
390 * Returns a read-only (constant) reverse iterator that points to the
391 * last pair in the %multimap. Iteration is done in descending order
392 * according to the keys.
394 const_reverse_iterator
395 crbegin() const
396 { return _M_t.rbegin(); }
399 * Returns a read-only (constant) reverse iterator that points to one
400 * before the first pair in the %multimap. Iteration is done in
401 * descending order according to the keys.
403 const_reverse_iterator
404 crend() const
405 { return _M_t.rend(); }
406 #endif
408 // capacity
409 /** Returns true if the %multimap is empty. */
410 bool
411 empty() const
412 { return _M_t.empty(); }
414 /** Returns the size of the %multimap. */
415 size_type
416 size() const
417 { return _M_t.size(); }
419 /** Returns the maximum size of the %multimap. */
420 size_type
421 max_size() const
422 { return _M_t.max_size(); }
424 // modifiers
426 * @brief Inserts a std::pair into the %multimap.
427 * @param x Pair to be inserted (see std::make_pair for easy creation
428 * of pairs).
429 * @return An iterator that points to the inserted (key,value) pair.
431 * This function inserts a (key, value) pair into the %multimap.
432 * Contrary to a std::map the %multimap does not rely on unique keys and
433 * thus multiple pairs with the same key can be inserted.
435 * Insertion requires logarithmic time.
437 iterator
438 insert(const value_type& __x)
439 { return _M_t._M_insert_equal(__x); }
441 #ifdef __GXX_EXPERIMENTAL_CXX0X__
442 template<typename _Pair, typename = typename
443 std::enable_if<std::is_convertible<_Pair,
444 value_type>::value>::type>
445 iterator
446 insert(_Pair&& __x)
447 { return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
448 #endif
451 * @brief Inserts a std::pair into the %multimap.
452 * @param position An iterator that serves as a hint as to where the
453 * pair should be inserted.
454 * @param x Pair to be inserted (see std::make_pair for easy creation
455 * of pairs).
456 * @return An iterator that points to the inserted (key,value) pair.
458 * This function inserts a (key, value) pair into the %multimap.
459 * Contrary to a std::map the %multimap does not rely on unique keys and
460 * thus multiple pairs with the same key can be inserted.
461 * Note that the first parameter is only a hint and can potentially
462 * improve the performance of the insertion process. A bad hint would
463 * cause no gains in efficiency.
465 * For more on @a hinting, see:
466 * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
468 * Insertion requires logarithmic time (if the hint is not taken).
470 iterator
471 #ifdef __GXX_EXPERIMENTAL_CXX0X__
472 insert(const_iterator __position, const value_type& __x)
473 #else
474 insert(iterator __position, const value_type& __x)
475 #endif
476 { return _M_t._M_insert_equal_(__position, __x); }
478 #ifdef __GXX_EXPERIMENTAL_CXX0X__
479 template<typename _Pair, typename = typename
480 std::enable_if<std::is_convertible<_Pair,
481 value_type>::value>::type>
482 iterator
483 insert(const_iterator __position, _Pair&& __x)
484 { return _M_t._M_insert_equal_(__position,
485 std::forward<_Pair>(__x)); }
486 #endif
489 * @brief A template function that attempts to insert a range
490 * of elements.
491 * @param first Iterator pointing to the start of the range to be
492 * inserted.
493 * @param last Iterator pointing to the end of the range.
495 * Complexity similar to that of the range constructor.
497 template<typename _InputIterator>
498 void
499 insert(_InputIterator __first, _InputIterator __last)
500 { _M_t._M_insert_equal(__first, __last); }
502 #ifdef __GXX_EXPERIMENTAL_CXX0X__
504 * @brief Attempts to insert a list of std::pairs into the %multimap.
505 * @param list A std::initializer_list<value_type> of pairs to be
506 * inserted.
508 * Complexity similar to that of the range constructor.
510 void
511 insert(initializer_list<value_type> __l)
512 { this->insert(__l.begin(), __l.end()); }
513 #endif
515 #ifdef __GXX_EXPERIMENTAL_CXX0X__
516 // _GLIBCXX_RESOLVE_LIB_DEFECTS
517 // DR 130. Associative erase should return an iterator.
519 * @brief Erases an element from a %multimap.
520 * @param position An iterator pointing to the element to be erased.
521 * @return An iterator pointing to the element immediately following
522 * @a position prior to the element being erased. If no such
523 * element exists, end() is returned.
525 * This function erases an element, pointed to by the given iterator,
526 * from a %multimap. Note that this function only erases the element,
527 * and that if the element is itself a pointer, the pointed-to memory is
528 * not touched in any way. Managing the pointer is the user's
529 * responsibility.
531 iterator
532 erase(const_iterator __position)
533 { return _M_t.erase(__position); }
534 #else
536 * @brief Erases an element from a %multimap.
537 * @param position An iterator pointing to the element to be erased.
539 * This function erases an element, pointed to by the given iterator,
540 * from a %multimap. Note that this function only erases the element,
541 * and that if the element is itself a pointer, the pointed-to memory is
542 * not touched in any way. Managing the pointer is the user's
543 * responsibility.
545 void
546 erase(iterator __position)
547 { _M_t.erase(__position); }
548 #endif
551 * @brief Erases elements according to the provided key.
552 * @param x Key of element to be erased.
553 * @return The number of elements erased.
555 * This function erases all elements located by the given key from a
556 * %multimap.
557 * Note that this function only erases the element, and that if
558 * the element is itself a pointer, the pointed-to memory is not touched
559 * in any way. Managing the pointer is the user's responsibility.
561 size_type
562 erase(const key_type& __x)
563 { return _M_t.erase(__x); }
565 #ifdef __GXX_EXPERIMENTAL_CXX0X__
566 // _GLIBCXX_RESOLVE_LIB_DEFECTS
567 // DR 130. Associative erase should return an iterator.
569 * @brief Erases a [first,last) range of elements from a %multimap.
570 * @param first Iterator pointing to the start of the range to be
571 * erased.
572 * @param last Iterator pointing to the end of the range to be erased.
573 * @return The iterator @a last.
575 * This function erases a sequence of elements from a %multimap.
576 * Note that this function only erases the elements, and that if
577 * the elements themselves are pointers, the pointed-to memory is not
578 * touched in any way. Managing the pointer is the user's
579 * responsibility.
581 iterator
582 erase(const_iterator __first, const_iterator __last)
583 { return _M_t.erase(__first, __last); }
584 #else
585 // _GLIBCXX_RESOLVE_LIB_DEFECTS
586 // DR 130. Associative erase should return an iterator.
588 * @brief Erases a [first,last) range of elements from a %multimap.
589 * @param first Iterator pointing to the start of the range to be
590 * erased.
591 * @param last Iterator pointing to the end of the range to be erased.
593 * This function erases a sequence of elements from a %multimap.
594 * Note that this function only erases the elements, and that if
595 * the elements themselves are pointers, the pointed-to memory is not
596 * touched in any way. Managing the pointer is the user's
597 * responsibility.
599 void
600 erase(iterator __first, iterator __last)
601 { _M_t.erase(__first, __last); }
602 #endif
605 * @brief Swaps data with another %multimap.
606 * @param x A %multimap of the same element and allocator types.
608 * This exchanges the elements between two multimaps in constant time.
609 * (It is only swapping a pointer, an integer, and an instance of
610 * the @c Compare type (which itself is often stateless and empty), so it
611 * should be quite fast.)
612 * Note that the global std::swap() function is specialized such that
613 * std::swap(m1,m2) will feed to this function.
615 void
616 swap(multimap& __x)
617 { _M_t.swap(__x._M_t); }
620 * Erases all elements in a %multimap. Note that this function only
621 * erases the elements, and that if the elements themselves are pointers,
622 * the pointed-to memory is not touched in any way. Managing the pointer
623 * is the user's responsibility.
625 void
626 clear()
627 { _M_t.clear(); }
629 // observers
631 * Returns the key comparison object out of which the %multimap
632 * was constructed.
634 key_compare
635 key_comp() const
636 { return _M_t.key_comp(); }
639 * Returns a value comparison object, built from the key comparison
640 * object out of which the %multimap was constructed.
642 value_compare
643 value_comp() const
644 { return value_compare(_M_t.key_comp()); }
646 // multimap operations
648 * @brief Tries to locate an element in a %multimap.
649 * @param x Key of (key, value) pair to be located.
650 * @return Iterator pointing to sought-after element,
651 * or end() if not found.
653 * This function takes a key and tries to locate the element with which
654 * the key matches. If successful the function returns an iterator
655 * pointing to the sought after %pair. If unsuccessful it returns the
656 * past-the-end ( @c end() ) iterator.
658 iterator
659 find(const key_type& __x)
660 { return _M_t.find(__x); }
663 * @brief Tries to locate an element in a %multimap.
664 * @param x Key of (key, value) pair to be located.
665 * @return Read-only (constant) iterator pointing to sought-after
666 * element, or end() if not found.
668 * This function takes a key and tries to locate the element with which
669 * the key matches. If successful the function returns a constant
670 * iterator pointing to the sought after %pair. If unsuccessful it
671 * returns the past-the-end ( @c end() ) iterator.
673 const_iterator
674 find(const key_type& __x) const
675 { return _M_t.find(__x); }
678 * @brief Finds the number of elements with given key.
679 * @param x Key of (key, value) pairs to be located.
680 * @return Number of elements with specified key.
682 size_type
683 count(const key_type& __x) const
684 { return _M_t.count(__x); }
687 * @brief Finds the beginning of a subsequence matching given key.
688 * @param x Key of (key, value) pair to be located.
689 * @return Iterator pointing to first element equal to or greater
690 * than key, or end().
692 * This function returns the first element of a subsequence of elements
693 * that matches the given key. If unsuccessful it returns an iterator
694 * pointing to the first element that has a greater value than given key
695 * or end() if no such element exists.
697 iterator
698 lower_bound(const key_type& __x)
699 { return _M_t.lower_bound(__x); }
702 * @brief Finds the beginning of a subsequence matching given key.
703 * @param x Key of (key, value) pair to be located.
704 * @return Read-only (constant) iterator pointing to first element
705 * equal to or greater than key, or end().
707 * This function returns the first element of a subsequence of elements
708 * that matches the given key. If unsuccessful the iterator will point
709 * to the next greatest element or, if no such greater element exists, to
710 * end().
712 const_iterator
713 lower_bound(const key_type& __x) const
714 { return _M_t.lower_bound(__x); }
717 * @brief Finds the end of a subsequence matching given key.
718 * @param x Key of (key, value) pair to be located.
719 * @return Iterator pointing to the first element
720 * greater than key, or end().
722 iterator
723 upper_bound(const key_type& __x)
724 { return _M_t.upper_bound(__x); }
727 * @brief Finds the end of a subsequence matching given key.
728 * @param x Key of (key, value) pair to be located.
729 * @return Read-only (constant) iterator pointing to first iterator
730 * greater than key, or end().
732 const_iterator
733 upper_bound(const key_type& __x) const
734 { return _M_t.upper_bound(__x); }
737 * @brief Finds a subsequence matching given key.
738 * @param x Key of (key, value) pairs to be located.
739 * @return Pair of iterators that possibly points to the subsequence
740 * matching given key.
742 * This function is equivalent to
743 * @code
744 * std::make_pair(c.lower_bound(val),
745 * c.upper_bound(val))
746 * @endcode
747 * (but is faster than making the calls separately).
749 std::pair<iterator, iterator>
750 equal_range(const key_type& __x)
751 { return _M_t.equal_range(__x); }
754 * @brief Finds a subsequence matching given key.
755 * @param x Key of (key, value) pairs to be located.
756 * @return Pair of read-only (constant) iterators that possibly points
757 * to the subsequence matching given key.
759 * This function is equivalent to
760 * @code
761 * std::make_pair(c.lower_bound(val),
762 * c.upper_bound(val))
763 * @endcode
764 * (but is faster than making the calls separately).
766 std::pair<const_iterator, const_iterator>
767 equal_range(const key_type& __x) const
768 { return _M_t.equal_range(__x); }
770 template<typename _K1, typename _T1, typename _C1, typename _A1>
771 friend bool
772 operator==(const multimap<_K1, _T1, _C1, _A1>&,
773 const multimap<_K1, _T1, _C1, _A1>&);
775 template<typename _K1, typename _T1, typename _C1, typename _A1>
776 friend bool
777 operator<(const multimap<_K1, _T1, _C1, _A1>&,
778 const multimap<_K1, _T1, _C1, _A1>&);
782 * @brief Multimap equality comparison.
783 * @param x A %multimap.
784 * @param y A %multimap of the same type as @a x.
785 * @return True iff the size and elements of the maps are equal.
787 * This is an equivalence relation. It is linear in the size of the
788 * multimaps. Multimaps are considered equivalent if their sizes are equal,
789 * and if corresponding elements compare equal.
791 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
792 inline bool
793 operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
794 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
795 { return __x._M_t == __y._M_t; }
798 * @brief Multimap ordering relation.
799 * @param x A %multimap.
800 * @param y A %multimap of the same type as @a x.
801 * @return True iff @a x is lexicographically less than @a y.
803 * This is a total ordering relation. It is linear in the size of the
804 * multimaps. The elements must be comparable with @c <.
806 * See std::lexicographical_compare() for how the determination is made.
808 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
809 inline bool
810 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
811 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
812 { return __x._M_t < __y._M_t; }
814 /// Based on operator==
815 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
816 inline bool
817 operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
818 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
819 { return !(__x == __y); }
821 /// Based on operator<
822 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
823 inline bool
824 operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
825 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
826 { return __y < __x; }
828 /// Based on operator<
829 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
830 inline bool
831 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
832 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
833 { return !(__y < __x); }
835 /// Based on operator<
836 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
837 inline bool
838 operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
839 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
840 { return !(__x < __y); }
842 /// See std::multimap::swap().
843 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
844 inline void
845 swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
846 multimap<_Key, _Tp, _Compare, _Alloc>& __y)
847 { __x.swap(__y); }
849 _GLIBCXX_END_NESTED_NAMESPACE
851 #endif /* _STL_MULTIMAP_H */