]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/bits/stl_multimap.h
auto_ptr.h: Fix comment typos.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / stl_multimap.h
1 // Multimap implementation -*- C++ -*-
2
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
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 2, or (at your option)
10 // any later version.
11
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.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 /*
32 *
33 * Copyright (c) 1994
34 * Hewlett-Packard Company
35 *
36 * Permission to use, copy, modify, distribute and sell this software
37 * and its documentation for any purpose is hereby granted without fee,
38 * provided that the above copyright notice appear in all copies and
39 * that both that copyright notice and this permission notice appear
40 * in supporting documentation. Hewlett-Packard Company makes no
41 * representations about the suitability of this software for any
42 * purpose. It is provided "as is" without express or implied warranty.
43 *
44 *
45 * Copyright (c) 1996,1997
46 * Silicon Graphics Computer Systems, Inc.
47 *
48 * Permission to use, copy, modify, distribute and sell this software
49 * and its documentation for any purpose is hereby granted without fee,
50 * provided that the above copyright notice appear in all copies and
51 * that both that copyright notice and this permission notice appear
52 * in supporting documentation. Silicon Graphics makes no
53 * representations about the suitability of this software for any
54 * purpose. It is provided "as is" without express or implied warranty.
55 */
56
57 /** @file stl_multimap.h
58 * This is an internal header file, included by other library headers.
59 * You should not attempt to use it directly.
60 */
61
62 #ifndef _STL_MULTIMAP_H
63 #define _STL_MULTIMAP_H 1
64
65 #include <bits/concept_check.h>
66
67 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
68
69 /**
70 * @brief A standard container made up of (key,value) pairs, which can be
71 * retrieved based on a key, in logarithmic time.
72 *
73 * @ingroup Containers
74 * @ingroup Assoc_containers
75 *
76 * Meets the requirements of a <a href="tables.html#65">container</a>, a
77 * <a href="tables.html#66">reversible container</a>, and an
78 * <a href="tables.html#69">associative container</a> (using equivalent
79 * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
80 * is T, and the value_type is std::pair<const Key,T>.
81 *
82 * Multimaps support bidirectional iterators.
83 *
84 * The private tree data is declared exactly the same way for map and
85 * multimap; the distinction is made entirely in how the tree functions are
86 * called (*_unique versus *_equal, same as the standard).
87 */
88 template <typename _Key, typename _Tp,
89 typename _Compare = std::less<_Key>,
90 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
91 class multimap
92 {
93 public:
94 typedef _Key key_type;
95 typedef _Tp mapped_type;
96 typedef std::pair<const _Key, _Tp> value_type;
97 typedef _Compare key_compare;
98 typedef _Alloc allocator_type;
99
100 private:
101 // concept requirements
102 typedef typename _Alloc::value_type _Alloc_value_type;
103 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
104 __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
105 _BinaryFunctionConcept)
106 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
107
108 public:
109 class value_compare
110 : public std::binary_function<value_type, value_type, bool>
111 {
112 friend class multimap<_Key, _Tp, _Compare, _Alloc>;
113 protected:
114 _Compare comp;
115
116 value_compare(_Compare __c)
117 : comp(__c) { }
118
119 public:
120 bool operator()(const value_type& __x, const value_type& __y) const
121 { return comp(__x.first, __y.first); }
122 };
123
124 private:
125 /// This turns a red-black tree into a [multi]map.
126 typedef typename _Alloc::template rebind<value_type>::other
127 _Pair_alloc_type;
128
129 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
130 key_compare, _Pair_alloc_type> _Rep_type;
131 /// The actual tree structure.
132 _Rep_type _M_t;
133
134 public:
135 // many of these are specified differently in ISO, but the following are
136 // "functionally equivalent"
137 typedef typename _Pair_alloc_type::pointer pointer;
138 typedef typename _Pair_alloc_type::const_pointer const_pointer;
139 typedef typename _Pair_alloc_type::reference reference;
140 typedef typename _Pair_alloc_type::const_reference const_reference;
141 typedef typename _Rep_type::iterator iterator;
142 typedef typename _Rep_type::const_iterator const_iterator;
143 typedef typename _Rep_type::size_type size_type;
144 typedef typename _Rep_type::difference_type difference_type;
145 typedef typename _Rep_type::reverse_iterator reverse_iterator;
146 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
147
148 // [23.3.2] construct/copy/destroy
149 // (get_allocator() is also listed in this section)
150 /**
151 * @brief Default constructor creates no elements.
152 */
153 multimap()
154 : _M_t() { }
155
156 /**
157 * @brief Creates a %multimap with no elements.
158 * @param comp A comparison object.
159 * @param a An allocator object.
160 */
161 explicit
162 multimap(const _Compare& __comp,
163 const allocator_type& __a = allocator_type())
164 : _M_t(__comp, __a) { }
165
166 /**
167 * @brief %Multimap copy constructor.
168 * @param x A %multimap of identical element and allocator types.
169 *
170 * The newly-created %multimap uses a copy of the allocation object
171 * used by @a x.
172 */
173 multimap(const multimap& __x)
174 : _M_t(__x._M_t) { }
175
176 #ifdef __GXX_EXPERIMENTAL_CXX0X__
177 /**
178 * @brief %Multimap move constructor.
179 * @param x A %multimap of identical element and allocator types.
180 *
181 * The newly-created %multimap contains the exact contents of @a x.
182 * The contents of @a x are a valid, but unspecified %multimap.
183 */
184 multimap(multimap&& __x)
185 : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
186 #endif
187
188 /**
189 * @brief Builds a %multimap from a range.
190 * @param first An input iterator.
191 * @param last An input iterator.
192 *
193 * Create a %multimap consisting of copies of the elements from
194 * [first,last). This is linear in N if the range is already sorted,
195 * and NlogN otherwise (where N is distance(first,last)).
196 */
197 template<typename _InputIterator>
198 multimap(_InputIterator __first, _InputIterator __last)
199 : _M_t()
200 { _M_t._M_insert_unique(__first, __last); }
201
202 /**
203 * @brief Builds a %multimap from a range.
204 * @param first An input iterator.
205 * @param last An input iterator.
206 * @param comp A comparison functor.
207 * @param a An allocator object.
208 *
209 * Create a %multimap consisting of copies of the elements from
210 * [first,last). This is linear in N if the range is already sorted,
211 * and NlogN otherwise (where N is distance(first,last)).
212 */
213 template<typename _InputIterator>
214 multimap(_InputIterator __first, _InputIterator __last,
215 const _Compare& __comp,
216 const allocator_type& __a = allocator_type())
217 : _M_t(__comp, __a)
218 { _M_t._M_insert_equal(__first, __last); }
219
220 // FIXME There is no dtor declared, but we should have something generated
221 // by Doxygen. I don't know what tags to add to this paragraph to make
222 // that happen:
223 /**
224 * The dtor only erases the elements, and note that if the elements
225 * themselves are pointers, the pointed-to memory is not touched in any
226 * way. Managing the pointer is the user's responsibility.
227 */
228
229 /**
230 * @brief %Multimap assignment operator.
231 * @param x A %multimap of identical element and allocator types.
232 *
233 * All the elements of @a x are copied, but unlike the copy constructor,
234 * the allocator object is not copied.
235 */
236 multimap&
237 operator=(const multimap& __x)
238 {
239 _M_t = __x._M_t;
240 return *this;
241 }
242
243 #ifdef __GXX_EXPERIMENTAL_CXX0X__
244 /**
245 * @brief %Multimap move assignment operator.
246 * @param x A %multimap of identical element and allocator types.
247 *
248 * The contents of @a x are moved into this multimap (without copying).
249 * @a x is a valid, but unspecified multimap.
250 */
251 multimap&
252 operator=(multimap&& __x)
253 {
254 // NB: DR 675.
255 this->clear();
256 this->swap(__x);
257 return *this;
258 }
259 #endif
260
261 /// Get a copy of the memory allocation object.
262 allocator_type
263 get_allocator() const
264 { return _M_t.get_allocator(); }
265
266 // iterators
267 /**
268 * Returns a read/write iterator that points to the first pair in the
269 * %multimap. Iteration is done in ascending order according to the
270 * keys.
271 */
272 iterator
273 begin()
274 { return _M_t.begin(); }
275
276 /**
277 * Returns a read-only (constant) iterator that points to the first pair
278 * in the %multimap. Iteration is done in ascending order according to
279 * the keys.
280 */
281 const_iterator
282 begin() const
283 { return _M_t.begin(); }
284
285 /**
286 * Returns a read/write iterator that points one past the last pair in
287 * the %multimap. Iteration is done in ascending order according to the
288 * keys.
289 */
290 iterator
291 end()
292 { return _M_t.end(); }
293
294 /**
295 * Returns a read-only (constant) iterator that points one past the last
296 * pair in the %multimap. Iteration is done in ascending order according
297 * to the keys.
298 */
299 const_iterator
300 end() const
301 { return _M_t.end(); }
302
303 /**
304 * Returns a read/write reverse iterator that points to the last pair in
305 * the %multimap. Iteration is done in descending order according to the
306 * keys.
307 */
308 reverse_iterator
309 rbegin()
310 { return _M_t.rbegin(); }
311
312 /**
313 * Returns a read-only (constant) reverse iterator that points to the
314 * last pair in the %multimap. Iteration is done in descending order
315 * according to the keys.
316 */
317 const_reverse_iterator
318 rbegin() const
319 { return _M_t.rbegin(); }
320
321 /**
322 * Returns a read/write reverse iterator that points to one before the
323 * first pair in the %multimap. Iteration is done in descending order
324 * according to the keys.
325 */
326 reverse_iterator
327 rend()
328 { return _M_t.rend(); }
329
330 /**
331 * Returns a read-only (constant) reverse iterator that points to one
332 * before the first pair in the %multimap. Iteration is done in
333 * descending order according to the keys.
334 */
335 const_reverse_iterator
336 rend() const
337 { return _M_t.rend(); }
338
339 #ifdef __GXX_EXPERIMENTAL_CXX0X__
340 /**
341 * Returns a read-only (constant) iterator that points to the first pair
342 * in the %multimap. Iteration is done in ascending order according to
343 * the keys.
344 */
345 const_iterator
346 cbegin() const
347 { return _M_t.begin(); }
348
349 /**
350 * Returns a read-only (constant) iterator that points one past the last
351 * pair in the %multimap. Iteration is done in ascending order according
352 * to the keys.
353 */
354 const_iterator
355 cend() const
356 { return _M_t.end(); }
357
358 /**
359 * Returns a read-only (constant) reverse iterator that points to the
360 * last pair in the %multimap. Iteration is done in descending order
361 * according to the keys.
362 */
363 const_reverse_iterator
364 crbegin() const
365 { return _M_t.rbegin(); }
366
367 /**
368 * Returns a read-only (constant) reverse iterator that points to one
369 * before the first pair in the %multimap. Iteration is done in
370 * descending order according to the keys.
371 */
372 const_reverse_iterator
373 crend() const
374 { return _M_t.rend(); }
375 #endif
376
377 // capacity
378 /** Returns true if the %multimap is empty. */
379 bool
380 empty() const
381 { return _M_t.empty(); }
382
383 /** Returns the size of the %multimap. */
384 size_type
385 size() const
386 { return _M_t.size(); }
387
388 /** Returns the maximum size of the %multimap. */
389 size_type
390 max_size() const
391 { return _M_t.max_size(); }
392
393 // modifiers
394 /**
395 * @brief Inserts a std::pair into the %multimap.
396 * @param x Pair to be inserted (see std::make_pair for easy creation
397 * of pairs).
398 * @return An iterator that points to the inserted (key,value) pair.
399 *
400 * This function inserts a (key, value) pair into the %multimap.
401 * Contrary to a std::map the %multimap does not rely on unique keys and
402 * thus multiple pairs with the same key can be inserted.
403 *
404 * Insertion requires logarithmic time.
405 */
406 iterator
407 insert(const value_type& __x)
408 { return _M_t._M_insert_equal(__x); }
409
410 /**
411 * @brief Inserts a std::pair into the %multimap.
412 * @param position An iterator that serves as a hint as to where the
413 * pair should be inserted.
414 * @param x Pair to be inserted (see std::make_pair for easy creation
415 * of pairs).
416 * @return An iterator that points to the inserted (key,value) pair.
417 *
418 * This function inserts a (key, value) pair into the %multimap.
419 * Contrary to a std::map the %multimap does not rely on unique keys and
420 * thus multiple pairs with the same key can be inserted.
421 * Note that the first parameter is only a hint and can potentially
422 * improve the performance of the insertion process. A bad hint would
423 * cause no gains in efficiency.
424 *
425 * See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
426 * for more on "hinting".
427 *
428 * Insertion requires logarithmic time (if the hint is not taken).
429 */
430 iterator
431 insert(iterator __position, const value_type& __x)
432 { return _M_t._M_insert_equal_(__position, __x); }
433
434 /**
435 * @brief A template function that attempts to insert a range of elements.
436 * @param first Iterator pointing to the start of the range to be
437 * inserted.
438 * @param last Iterator pointing to the end of the range.
439 *
440 * Complexity similar to that of the range constructor.
441 */
442 template<typename _InputIterator>
443 void
444 insert(_InputIterator __first, _InputIterator __last)
445 { _M_t._M_insert_equal(__first, __last); }
446
447 /**
448 * @brief Erases an element from a %multimap.
449 * @param position An iterator pointing to the element to be erased.
450 *
451 * This function erases an element, pointed to by the given iterator,
452 * from a %multimap. Note that this function only erases the element,
453 * and that if the element is itself a pointer, the pointed-to memory is
454 * not touched in any way. Managing the pointer is the user's
455 * responsibility.
456 */
457 void
458 erase(iterator __position)
459 { _M_t.erase(__position); }
460
461 /**
462 * @brief Erases elements according to the provided key.
463 * @param x Key of element to be erased.
464 * @return The number of elements erased.
465 *
466 * This function erases all elements located by the given key from a
467 * %multimap.
468 * Note that this function only erases the element, and that if
469 * the element is itself a pointer, the pointed-to memory is not touched
470 * in any way. Managing the pointer is the user's responsibility.
471 */
472 size_type
473 erase(const key_type& __x)
474 { return _M_t.erase(__x); }
475
476 /**
477 * @brief Erases a [first,last) range of elements from a %multimap.
478 * @param first Iterator pointing to the start of the range to be
479 * erased.
480 * @param last Iterator pointing to the end of the range to be erased.
481 *
482 * This function erases a sequence of elements from a %multimap.
483 * Note that this function only erases the elements, and that if
484 * the elements themselves are pointers, the pointed-to memory is not
485 * touched in any way. Managing the pointer is the user's responsibility.
486 */
487 void
488 erase(iterator __first, iterator __last)
489 { _M_t.erase(__first, __last); }
490
491 /**
492 * @brief Swaps data with another %multimap.
493 * @param x A %multimap of the same element and allocator types.
494 *
495 * This exchanges the elements between two multimaps in constant time.
496 * (It is only swapping a pointer, an integer, and an instance of
497 * the @c Compare type (which itself is often stateless and empty), so it
498 * should be quite fast.)
499 * Note that the global std::swap() function is specialized such that
500 * std::swap(m1,m2) will feed to this function.
501 */
502 void
503 #ifdef __GXX_EXPERIMENTAL_CXX0X__
504 swap(multimap&& __x)
505 #else
506 swap(multimap& __x)
507 #endif
508 { _M_t.swap(__x._M_t); }
509
510 /**
511 * Erases all elements in a %multimap. Note that this function only
512 * erases the elements, and that if the elements themselves are pointers,
513 * the pointed-to memory is not touched in any way. Managing the pointer
514 * is the user's responsibility.
515 */
516 void
517 clear()
518 { _M_t.clear(); }
519
520 // observers
521 /**
522 * Returns the key comparison object out of which the %multimap
523 * was constructed.
524 */
525 key_compare
526 key_comp() const
527 { return _M_t.key_comp(); }
528
529 /**
530 * Returns a value comparison object, built from the key comparison
531 * object out of which the %multimap was constructed.
532 */
533 value_compare
534 value_comp() const
535 { return value_compare(_M_t.key_comp()); }
536
537 // multimap operations
538 /**
539 * @brief Tries to locate an element in a %multimap.
540 * @param x Key of (key, value) pair to be located.
541 * @return Iterator pointing to sought-after element,
542 * or end() if not found.
543 *
544 * This function takes a key and tries to locate the element with which
545 * the key matches. If successful the function returns an iterator
546 * pointing to the sought after %pair. If unsuccessful it returns the
547 * past-the-end ( @c end() ) iterator.
548 */
549 iterator
550 find(const key_type& __x)
551 { return _M_t.find(__x); }
552
553 /**
554 * @brief Tries to locate an element in a %multimap.
555 * @param x Key of (key, value) pair to be located.
556 * @return Read-only (constant) iterator pointing to sought-after
557 * element, or end() if not found.
558 *
559 * This function takes a key and tries to locate the element with which
560 * the key matches. If successful the function returns a constant
561 * iterator pointing to the sought after %pair. If unsuccessful it
562 * returns the past-the-end ( @c end() ) iterator.
563 */
564 const_iterator
565 find(const key_type& __x) const
566 { return _M_t.find(__x); }
567
568 /**
569 * @brief Finds the number of elements with given key.
570 * @param x Key of (key, value) pairs to be located.
571 * @return Number of elements with specified key.
572 */
573 size_type
574 count(const key_type& __x) const
575 { return _M_t.count(__x); }
576
577 /**
578 * @brief Finds the beginning of a subsequence matching given key.
579 * @param x Key of (key, value) pair to be located.
580 * @return Iterator pointing to first element equal to or greater
581 * than key, or end().
582 *
583 * This function returns the first element of a subsequence of elements
584 * that matches the given key. If unsuccessful it returns an iterator
585 * pointing to the first element that has a greater value than given key
586 * or end() if no such element exists.
587 */
588 iterator
589 lower_bound(const key_type& __x)
590 { return _M_t.lower_bound(__x); }
591
592 /**
593 * @brief Finds the beginning of a subsequence matching given key.
594 * @param x Key of (key, value) pair to be located.
595 * @return Read-only (constant) iterator pointing to first element
596 * equal to or greater than key, or end().
597 *
598 * This function returns the first element of a subsequence of elements
599 * that matches the given key. If unsuccessful the iterator will point
600 * to the next greatest element or, if no such greater element exists, to
601 * end().
602 */
603 const_iterator
604 lower_bound(const key_type& __x) const
605 { return _M_t.lower_bound(__x); }
606
607 /**
608 * @brief Finds the end of a subsequence matching given key.
609 * @param x Key of (key, value) pair to be located.
610 * @return Iterator pointing to the first element
611 * greater than key, or end().
612 */
613 iterator
614 upper_bound(const key_type& __x)
615 { return _M_t.upper_bound(__x); }
616
617 /**
618 * @brief Finds the end of a subsequence matching given key.
619 * @param x Key of (key, value) pair to be located.
620 * @return Read-only (constant) iterator pointing to first iterator
621 * greater than key, or end().
622 */
623 const_iterator
624 upper_bound(const key_type& __x) const
625 { return _M_t.upper_bound(__x); }
626
627 /**
628 * @brief Finds a subsequence matching given key.
629 * @param x Key of (key, value) pairs to be located.
630 * @return Pair of iterators that possibly points to the subsequence
631 * matching given key.
632 *
633 * This function is equivalent to
634 * @code
635 * std::make_pair(c.lower_bound(val),
636 * c.upper_bound(val))
637 * @endcode
638 * (but is faster than making the calls separately).
639 */
640 std::pair<iterator, iterator>
641 equal_range(const key_type& __x)
642 { return _M_t.equal_range(__x); }
643
644 /**
645 * @brief Finds a subsequence matching given key.
646 * @param x Key of (key, value) pairs to be located.
647 * @return Pair of read-only (constant) iterators that possibly points
648 * to the subsequence matching given key.
649 *
650 * This function is equivalent to
651 * @code
652 * std::make_pair(c.lower_bound(val),
653 * c.upper_bound(val))
654 * @endcode
655 * (but is faster than making the calls separately).
656 */
657 std::pair<const_iterator, const_iterator>
658 equal_range(const key_type& __x) const
659 { return _M_t.equal_range(__x); }
660
661 template<typename _K1, typename _T1, typename _C1, typename _A1>
662 friend bool
663 operator==(const multimap<_K1, _T1, _C1, _A1>&,
664 const multimap<_K1, _T1, _C1, _A1>&);
665
666 template<typename _K1, typename _T1, typename _C1, typename _A1>
667 friend bool
668 operator<(const multimap<_K1, _T1, _C1, _A1>&,
669 const multimap<_K1, _T1, _C1, _A1>&);
670 };
671
672 /**
673 * @brief Multimap equality comparison.
674 * @param x A %multimap.
675 * @param y A %multimap of the same type as @a x.
676 * @return True iff the size and elements of the maps are equal.
677 *
678 * This is an equivalence relation. It is linear in the size of the
679 * multimaps. Multimaps are considered equivalent if their sizes are equal,
680 * and if corresponding elements compare equal.
681 */
682 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
683 inline bool
684 operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
685 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
686 { return __x._M_t == __y._M_t; }
687
688 /**
689 * @brief Multimap ordering relation.
690 * @param x A %multimap.
691 * @param y A %multimap of the same type as @a x.
692 * @return True iff @a x is lexicographically less than @a y.
693 *
694 * This is a total ordering relation. It is linear in the size of the
695 * multimaps. The elements must be comparable with @c <.
696 *
697 * See std::lexicographical_compare() for how the determination is made.
698 */
699 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
700 inline bool
701 operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
702 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
703 { return __x._M_t < __y._M_t; }
704
705 /// Based on operator==
706 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
707 inline bool
708 operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
709 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
710 { return !(__x == __y); }
711
712 /// Based on operator<
713 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
714 inline bool
715 operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
716 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
717 { return __y < __x; }
718
719 /// Based on operator<
720 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
721 inline bool
722 operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
723 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
724 { return !(__y < __x); }
725
726 /// Based on operator<
727 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
728 inline bool
729 operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
730 const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
731 { return !(__x < __y); }
732
733 /// See std::multimap::swap().
734 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
735 inline void
736 swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
737 multimap<_Key, _Tp, _Compare, _Alloc>& __y)
738 { __x.swap(__y); }
739
740 #ifdef __GXX_EXPERIMENTAL_CXX0X__
741 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
742 inline void
743 swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
744 multimap<_Key, _Tp, _Compare, _Alloc>& __y)
745 { __x.swap(__y); }
746
747 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
748 inline void
749 swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
750 multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
751 { __x.swap(__y); }
752 #endif
753
754 _GLIBCXX_END_NESTED_NAMESPACE
755
756 #endif /* _STL_MULTIMAP_H */