]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/include/bits/stl_multimap.h
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / 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_equal(__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        *  For more on "hinting," see:
426        *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
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
436        *  of elements.
437        *  @param  first  Iterator pointing to the start of the range to be
438        *                 inserted.
439        *  @param  last  Iterator pointing to the end of the range.
440        *
441        *  Complexity similar to that of the range constructor.
442        */
443       template<typename _InputIterator>
444         void
445         insert(_InputIterator __first, _InputIterator __last)
446         { _M_t._M_insert_equal(__first, __last); }
447
448       /**
449        *  @brief Erases an element from a %multimap.
450        *  @param  position  An iterator pointing to the element to be erased.
451        *
452        *  This function erases an element, pointed to by the given iterator,
453        *  from a %multimap.  Note that this function only erases the element,
454        *  and that if the element is itself a pointer, the pointed-to memory is
455        *  not touched in any way.  Managing the pointer is the user's
456        *  responsibility.
457        */
458       void
459       erase(iterator __position)
460       { _M_t.erase(__position); }
461
462       /**
463        *  @brief Erases elements according to the provided key.
464        *  @param  x  Key of element to be erased.
465        *  @return  The number of elements erased.
466        *
467        *  This function erases all elements located by the given key from a
468        *  %multimap.
469        *  Note that this function only erases the element, and that if
470        *  the element is itself a pointer, the pointed-to memory is not touched
471        *  in any way.  Managing the pointer is the user's responsibility.
472        */
473       size_type
474       erase(const key_type& __x)
475       { return _M_t.erase(__x); }
476
477       /**
478        *  @brief Erases a [first,last) range of elements from a %multimap.
479        *  @param  first  Iterator pointing to the start of the range to be
480        *                 erased.
481        *  @param  last  Iterator pointing to the end of the range to be erased.
482        *
483        *  This function erases a sequence of elements from a %multimap.
484        *  Note that this function only erases the elements, and that if
485        *  the elements themselves are pointers, the pointed-to memory is not
486        *  touched in any way.  Managing the pointer is the user's responsibility.
487        */
488       void
489       erase(iterator __first, iterator __last)
490       { _M_t.erase(__first, __last); }
491
492       /**
493        *  @brief  Swaps data with another %multimap.
494        *  @param  x  A %multimap of the same element and allocator types.
495        *
496        *  This exchanges the elements between two multimaps in constant time.
497        *  (It is only swapping a pointer, an integer, and an instance of
498        *  the @c Compare type (which itself is often stateless and empty), so it
499        *  should be quite fast.)
500        *  Note that the global std::swap() function is specialized such that
501        *  std::swap(m1,m2) will feed to this function.
502        */
503       void
504 #ifdef __GXX_EXPERIMENTAL_CXX0X__
505       swap(multimap&& __x)
506 #else
507       swap(multimap& __x)
508 #endif
509       { _M_t.swap(__x._M_t); }
510
511       /**
512        *  Erases all elements in a %multimap.  Note that this function only
513        *  erases the elements, and that if the elements themselves are pointers,
514        *  the pointed-to memory is not touched in any way.  Managing the pointer
515        *  is the user's responsibility.
516        */
517       void
518       clear()
519       { _M_t.clear(); }
520
521       // observers
522       /**
523        *  Returns the key comparison object out of which the %multimap
524        *  was constructed.
525        */
526       key_compare
527       key_comp() const
528       { return _M_t.key_comp(); }
529
530       /**
531        *  Returns a value comparison object, built from the key comparison
532        *  object out of which the %multimap was constructed.
533        */
534       value_compare
535       value_comp() const
536       { return value_compare(_M_t.key_comp()); }
537
538       // multimap operations
539       /**
540        *  @brief Tries to locate an element in a %multimap.
541        *  @param  x  Key of (key, value) pair to be located.
542        *  @return  Iterator pointing to sought-after element,
543        *           or end() if not found.
544        *
545        *  This function takes a key and tries to locate the element with which
546        *  the key matches.  If successful the function returns an iterator
547        *  pointing to the sought after %pair.  If unsuccessful it returns the
548        *  past-the-end ( @c end() ) iterator.
549        */
550       iterator
551       find(const key_type& __x)
552       { return _M_t.find(__x); }
553
554       /**
555        *  @brief Tries to locate an element in a %multimap.
556        *  @param  x  Key of (key, value) pair to be located.
557        *  @return  Read-only (constant) iterator pointing to sought-after
558        *           element, or end() if not found.
559        *
560        *  This function takes a key and tries to locate the element with which
561        *  the key matches.  If successful the function returns a constant
562        *  iterator pointing to the sought after %pair.  If unsuccessful it
563        *  returns the past-the-end ( @c end() ) iterator.
564        */
565       const_iterator
566       find(const key_type& __x) const
567       { return _M_t.find(__x); }
568
569       /**
570        *  @brief Finds the number of elements with given key.
571        *  @param  x  Key of (key, value) pairs to be located.
572        *  @return Number of elements with specified key.
573        */
574       size_type
575       count(const key_type& __x) const
576       { return _M_t.count(__x); }
577
578       /**
579        *  @brief Finds the beginning of a subsequence matching given key.
580        *  @param  x  Key of (key, value) pair to be located.
581        *  @return  Iterator pointing to first element equal to or greater
582        *           than key, or end().
583        *
584        *  This function returns the first element of a subsequence of elements
585        *  that matches the given key.  If unsuccessful it returns an iterator
586        *  pointing to the first element that has a greater value than given key
587        *  or end() if no such element exists.
588        */
589       iterator
590       lower_bound(const key_type& __x)
591       { return _M_t.lower_bound(__x); }
592
593       /**
594        *  @brief Finds the beginning of a subsequence matching given key.
595        *  @param  x  Key of (key, value) pair to be located.
596        *  @return  Read-only (constant) iterator pointing to first element
597        *           equal to or greater than key, or end().
598        *
599        *  This function returns the first element of a subsequence of elements
600        *  that matches the given key.  If unsuccessful the iterator will point
601        *  to the next greatest element or, if no such greater element exists, to
602        *  end().
603        */
604       const_iterator
605       lower_bound(const key_type& __x) const
606       { return _M_t.lower_bound(__x); }
607
608       /**
609        *  @brief Finds the end of a subsequence matching given key.
610        *  @param  x  Key of (key, value) pair to be located.
611        *  @return Iterator pointing to the first element
612        *          greater than key, or end().
613        */
614       iterator
615       upper_bound(const key_type& __x)
616       { return _M_t.upper_bound(__x); }
617
618       /**
619        *  @brief Finds the end of a subsequence matching given key.
620        *  @param  x  Key of (key, value) pair to be located.
621        *  @return  Read-only (constant) iterator pointing to first iterator
622        *           greater than key, or end().
623        */
624       const_iterator
625       upper_bound(const key_type& __x) const
626       { return _M_t.upper_bound(__x); }
627
628       /**
629        *  @brief Finds a subsequence matching given key.
630        *  @param  x  Key of (key, value) pairs to be located.
631        *  @return  Pair of iterators that possibly points to the subsequence
632        *           matching given key.
633        *
634        *  This function is equivalent to
635        *  @code
636        *    std::make_pair(c.lower_bound(val),
637        *                   c.upper_bound(val))
638        *  @endcode
639        *  (but is faster than making the calls separately).
640        */
641       std::pair<iterator, iterator>
642       equal_range(const key_type& __x)
643       { return _M_t.equal_range(__x); }
644
645       /**
646        *  @brief Finds a subsequence matching given key.
647        *  @param  x  Key of (key, value) pairs to be located.
648        *  @return  Pair of read-only (constant) iterators that possibly points
649        *           to the subsequence matching given key.
650        *
651        *  This function is equivalent to
652        *  @code
653        *    std::make_pair(c.lower_bound(val),
654        *                   c.upper_bound(val))
655        *  @endcode
656        *  (but is faster than making the calls separately).
657        */
658       std::pair<const_iterator, const_iterator>
659       equal_range(const key_type& __x) const
660       { return _M_t.equal_range(__x); }
661
662       template<typename _K1, typename _T1, typename _C1, typename _A1>
663         friend bool
664         operator==(const multimap<_K1, _T1, _C1, _A1>&,
665                    const multimap<_K1, _T1, _C1, _A1>&);
666
667       template<typename _K1, typename _T1, typename _C1, typename _A1>
668         friend bool
669         operator<(const multimap<_K1, _T1, _C1, _A1>&,
670                   const multimap<_K1, _T1, _C1, _A1>&);
671   };
672
673   /**
674    *  @brief  Multimap equality comparison.
675    *  @param  x  A %multimap.
676    *  @param  y  A %multimap of the same type as @a x.
677    *  @return  True iff the size and elements of the maps are equal.
678    *
679    *  This is an equivalence relation.  It is linear in the size of the
680    *  multimaps.  Multimaps are considered equivalent if their sizes are equal,
681    *  and if corresponding elements compare equal.
682   */
683   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
684     inline bool
685     operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
686                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
687     { return __x._M_t == __y._M_t; }
688
689   /**
690    *  @brief  Multimap ordering relation.
691    *  @param  x  A %multimap.
692    *  @param  y  A %multimap of the same type as @a x.
693    *  @return  True iff @a x is lexicographically less than @a y.
694    *
695    *  This is a total ordering relation.  It is linear in the size of the
696    *  multimaps.  The elements must be comparable with @c <.
697    *
698    *  See std::lexicographical_compare() for how the determination is made.
699   */
700   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
701     inline bool
702     operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
703               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
704     { return __x._M_t < __y._M_t; }
705
706   /// Based on operator==
707   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
708     inline bool
709     operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
710                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
711     { return !(__x == __y); }
712
713   /// Based on operator<
714   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
715     inline bool
716     operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
717               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
718     { return __y < __x; }
719
720   /// Based on operator<
721   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
722     inline bool
723     operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
724                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
725     { return !(__y < __x); }
726
727   /// Based on operator<
728   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
729     inline bool
730     operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
731                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
732     { return !(__x < __y); }
733
734   /// See std::multimap::swap().
735   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
736     inline void
737     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
738          multimap<_Key, _Tp, _Compare, _Alloc>& __y)
739     { __x.swap(__y); }
740
741 #ifdef __GXX_EXPERIMENTAL_CXX0X__
742   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
743     inline void
744     swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
745          multimap<_Key, _Tp, _Compare, _Alloc>& __y)
746     { __x.swap(__y); }
747
748   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
749     inline void
750     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
751          multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
752     { __x.swap(__y); }
753 #endif
754
755 _GLIBCXX_END_NESTED_NAMESPACE
756
757 #endif /* _STL_MULTIMAP_H */