stl_multimap.h

Go to the documentation of this file.
00001 // Multimap implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // You should have received a copy of the GNU General Public License along
00018 // with this library; see the file COPYING.  If not, write to the Free
00019 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00020 // USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 /*
00032  *
00033  * Copyright (c) 1994
00034  * Hewlett-Packard Company
00035  *
00036  * Permission to use, copy, modify, distribute and sell this software
00037  * and its documentation for any purpose is hereby granted without fee,
00038  * provided that the above copyright notice appear in all copies and
00039  * that both that copyright notice and this permission notice appear
00040  * in supporting documentation.  Hewlett-Packard Company makes no
00041  * representations about the suitability of this software for any
00042  * purpose.  It is provided "as is" without express or implied warranty.
00043  *
00044  *
00045  * Copyright (c) 1996,1997
00046  * Silicon Graphics Computer Systems, Inc.
00047  *
00048  * Permission to use, copy, modify, distribute and sell this software
00049  * and its documentation for any purpose is hereby granted without fee,
00050  * provided that the above copyright notice appear in all copies and
00051  * that both that copyright notice and this permission notice appear
00052  * in supporting documentation.  Silicon Graphics makes no
00053  * representations about the suitability of this software for any
00054  * purpose.  It is provided "as is" without express or implied warranty.
00055  */
00056 
00057 /** @file stl_multimap.h
00058  *  This is an internal header file, included by other library headers.
00059  *  You should not attempt to use it directly.
00060  */
00061 
00062 #ifndef _STL_MULTIMAP_H
00063 #define _STL_MULTIMAP_H 1
00064 
00065 #include <bits/concept_check.h>
00066 
00067 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
00068 
00069   /**
00070    *  @brief A standard container made up of (key,value) pairs, which can be
00071    *  retrieved based on a key, in logarithmic time.
00072    *
00073    *  @ingroup Containers
00074    *  @ingroup Assoc_containers
00075    *
00076    *  Meets the requirements of a <a href="tables.html#65">container</a>, a
00077    *  <a href="tables.html#66">reversible container</a>, and an
00078    *  <a href="tables.html#69">associative container</a> (using equivalent
00079    *  keys).  For a @c multimap<Key,T> the key_type is Key, the mapped_type
00080    *  is T, and the value_type is std::pair<const Key,T>.
00081    *
00082    *  Multimaps support bidirectional iterators.
00083    *
00084    *  The private tree data is declared exactly the same way for map and
00085    *  multimap; the distinction is made entirely in how the tree functions are
00086    *  called (*_unique versus *_equal, same as the standard).
00087   */
00088   template <typename _Key, typename _Tp,
00089         typename _Compare = std::less<_Key>,
00090         typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
00091     class multimap
00092     {
00093     public:
00094       typedef _Key                                          key_type;
00095       typedef _Tp                                           mapped_type;
00096       typedef std::pair<const _Key, _Tp>                    value_type;
00097       typedef _Compare                                      key_compare;
00098       typedef _Alloc                                        allocator_type;
00099 
00100     private:
00101       // concept requirements
00102       typedef typename _Alloc::value_type                   _Alloc_value_type;
00103       __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
00104       __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
00105                 _BinaryFunctionConcept)
00106       __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)    
00107 
00108     public:
00109       class value_compare
00110       : public std::binary_function<value_type, value_type, bool>
00111       {
00112     friend class multimap<_Key, _Tp, _Compare, _Alloc>;
00113       protected:
00114     _Compare comp;
00115 
00116     value_compare(_Compare __c)
00117     : comp(__c) { }
00118 
00119       public:
00120     bool operator()(const value_type& __x, const value_type& __y) const
00121     { return comp(__x.first, __y.first); }
00122       };
00123 
00124     private:
00125       /// This turns a red-black tree into a [multi]map.
00126       typedef typename _Alloc::template rebind<value_type>::other 
00127         _Pair_alloc_type;
00128 
00129       typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
00130                key_compare, _Pair_alloc_type> _Rep_type;
00131       /// The actual tree structure.
00132       _Rep_type _M_t;
00133 
00134     public:
00135       // many of these are specified differently in ISO, but the following are
00136       // "functionally equivalent"
00137       typedef typename _Pair_alloc_type::pointer         pointer;
00138       typedef typename _Pair_alloc_type::const_pointer   const_pointer;
00139       typedef typename _Pair_alloc_type::reference       reference;
00140       typedef typename _Pair_alloc_type::const_reference const_reference;
00141       typedef typename _Rep_type::iterator               iterator;
00142       typedef typename _Rep_type::const_iterator         const_iterator;
00143       typedef typename _Rep_type::size_type              size_type;
00144       typedef typename _Rep_type::difference_type        difference_type;
00145       typedef typename _Rep_type::reverse_iterator       reverse_iterator;
00146       typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
00147 
00148       // [23.3.2] construct/copy/destroy
00149       // (get_allocator() is also listed in this section)
00150       /**
00151        *  @brief  Default constructor creates no elements.
00152        */
00153       multimap()
00154       : _M_t() { }
00155 
00156       /**
00157        *  @brief  Creates a %multimap with no elements.
00158        *  @param  comp  A comparison object.
00159        *  @param  a  An allocator object.
00160        */
00161       explicit
00162       multimap(const _Compare& __comp,
00163            const allocator_type& __a = allocator_type())
00164       : _M_t(__comp, __a) { }
00165 
00166       /**
00167        *  @brief  %Multimap copy constructor.
00168        *  @param  x  A %multimap of identical element and allocator types.
00169        *
00170        *  The newly-created %multimap uses a copy of the allocation object
00171        *  used by @a x.
00172        */
00173       multimap(const multimap& __x)
00174       : _M_t(__x._M_t) { }
00175 
00176 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00177       /**
00178        *  @brief  %Multimap move constructor.
00179        *  @param   x  A %multimap of identical element and allocator types.
00180        *
00181        *  The newly-created %multimap contains the exact contents of @a x.
00182        *  The contents of @a x are a valid, but unspecified %multimap.
00183        */
00184       multimap(multimap&& __x)
00185       : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
00186 #endif
00187 
00188       /**
00189        *  @brief  Builds a %multimap from a range.
00190        *  @param  first  An input iterator.
00191        *  @param  last  An input iterator.
00192        *
00193        *  Create a %multimap consisting of copies of the elements from
00194        *  [first,last).  This is linear in N if the range is already sorted,
00195        *  and NlogN otherwise (where N is distance(first,last)).
00196        */
00197       template<typename _InputIterator>
00198         multimap(_InputIterator __first, _InputIterator __last)
00199     : _M_t()
00200         { _M_t._M_insert_equal(__first, __last); }
00201 
00202       /**
00203        *  @brief  Builds a %multimap from a range.
00204        *  @param  first  An input iterator.
00205        *  @param  last  An input iterator.
00206        *  @param  comp  A comparison functor.
00207        *  @param  a  An allocator object.
00208        *
00209        *  Create a %multimap consisting of copies of the elements from
00210        *  [first,last).  This is linear in N if the range is already sorted,
00211        *  and NlogN otherwise (where N is distance(first,last)).
00212        */
00213       template<typename _InputIterator>
00214         multimap(_InputIterator __first, _InputIterator __last,
00215          const _Compare& __comp,
00216          const allocator_type& __a = allocator_type())
00217         : _M_t(__comp, __a)
00218         { _M_t._M_insert_equal(__first, __last); }
00219 
00220       // FIXME There is no dtor declared, but we should have something generated
00221       // by Doxygen.  I don't know what tags to add to this paragraph to make
00222       // that happen:
00223       /**
00224        *  The dtor only erases the elements, and note that if the elements
00225        *  themselves are pointers, the pointed-to memory is not touched in any
00226        *  way.  Managing the pointer is the user's responsibility.
00227        */
00228 
00229       /**
00230        *  @brief  %Multimap assignment operator.
00231        *  @param  x  A %multimap of identical element and allocator types.
00232        *
00233        *  All the elements of @a x are copied, but unlike the copy constructor,
00234        *  the allocator object is not copied.
00235        */
00236       multimap&
00237       operator=(const multimap& __x)
00238       {
00239     _M_t = __x._M_t;
00240     return *this;
00241       }
00242 
00243 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00244       /**
00245        *  @brief  %Multimap move assignment operator.
00246        *  @param  x  A %multimap of identical element and allocator types.
00247        *
00248        *  The contents of @a x are moved into this multimap (without copying).
00249        *  @a x is a valid, but unspecified multimap.
00250        */
00251       multimap&
00252       operator=(multimap&& __x)
00253       {
00254     // NB: DR 675.
00255     this->clear();
00256     this->swap(__x); 
00257     return *this;
00258       }
00259 #endif
00260 
00261       /// Get a copy of the memory allocation object.
00262       allocator_type
00263       get_allocator() const
00264       { return _M_t.get_allocator(); }
00265 
00266       // iterators
00267       /**
00268        *  Returns a read/write iterator that points to the first pair in the
00269        *  %multimap.  Iteration is done in ascending order according to the
00270        *  keys.
00271        */
00272       iterator
00273       begin()
00274       { return _M_t.begin(); }
00275 
00276       /**
00277        *  Returns a read-only (constant) iterator that points to the first pair
00278        *  in the %multimap.  Iteration is done in ascending order according to
00279        *  the keys.
00280        */
00281       const_iterator
00282       begin() const
00283       { return _M_t.begin(); }
00284 
00285       /**
00286        *  Returns a read/write iterator that points one past the last pair in
00287        *  the %multimap.  Iteration is done in ascending order according to the
00288        *  keys.
00289        */
00290       iterator
00291       end()
00292       { return _M_t.end(); }
00293 
00294       /**
00295        *  Returns a read-only (constant) iterator that points one past the last
00296        *  pair in the %multimap.  Iteration is done in ascending order according
00297        *  to the keys.
00298        */
00299       const_iterator
00300       end() const
00301       { return _M_t.end(); }
00302 
00303       /**
00304        *  Returns a read/write reverse iterator that points to the last pair in
00305        *  the %multimap.  Iteration is done in descending order according to the
00306        *  keys.
00307        */
00308       reverse_iterator
00309       rbegin()
00310       { return _M_t.rbegin(); }
00311 
00312       /**
00313        *  Returns a read-only (constant) reverse iterator that points to the
00314        *  last pair in the %multimap.  Iteration is done in descending order
00315        *  according to the keys.
00316        */
00317       const_reverse_iterator
00318       rbegin() const
00319       { return _M_t.rbegin(); }
00320 
00321       /**
00322        *  Returns a read/write reverse iterator that points to one before the
00323        *  first pair in the %multimap.  Iteration is done in descending order
00324        *  according to the keys.
00325        */
00326       reverse_iterator
00327       rend()
00328       { return _M_t.rend(); }
00329 
00330       /**
00331        *  Returns a read-only (constant) reverse iterator that points to one
00332        *  before the first pair in the %multimap.  Iteration is done in
00333        *  descending order according to the keys.
00334        */
00335       const_reverse_iterator
00336       rend() const
00337       { return _M_t.rend(); }
00338 
00339 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00340       /**
00341        *  Returns a read-only (constant) iterator that points to the first pair
00342        *  in the %multimap.  Iteration is done in ascending order according to
00343        *  the keys.
00344        */
00345       const_iterator
00346       cbegin() const
00347       { return _M_t.begin(); }
00348 
00349       /**
00350        *  Returns a read-only (constant) iterator that points one past the last
00351        *  pair in the %multimap.  Iteration is done in ascending order according
00352        *  to the keys.
00353        */
00354       const_iterator
00355       cend() const
00356       { return _M_t.end(); }
00357 
00358       /**
00359        *  Returns a read-only (constant) reverse iterator that points to the
00360        *  last pair in the %multimap.  Iteration is done in descending order
00361        *  according to the keys.
00362        */
00363       const_reverse_iterator
00364       crbegin() const
00365       { return _M_t.rbegin(); }
00366 
00367       /**
00368        *  Returns a read-only (constant) reverse iterator that points to one
00369        *  before the first pair in the %multimap.  Iteration is done in
00370        *  descending order according to the keys.
00371        */
00372       const_reverse_iterator
00373       crend() const
00374       { return _M_t.rend(); }
00375 #endif
00376 
00377       // capacity
00378       /** Returns true if the %multimap is empty.  */
00379       bool
00380       empty() const
00381       { return _M_t.empty(); }
00382 
00383       /** Returns the size of the %multimap.  */
00384       size_type
00385       size() const
00386       { return _M_t.size(); }
00387 
00388       /** Returns the maximum size of the %multimap.  */
00389       size_type
00390       max_size() const
00391       { return _M_t.max_size(); }
00392 
00393       // modifiers
00394       /**
00395        *  @brief Inserts a std::pair into the %multimap.
00396        *  @param  x  Pair to be inserted (see std::make_pair for easy creation
00397        *             of pairs).
00398        *  @return An iterator that points to the inserted (key,value) pair.
00399        *
00400        *  This function inserts a (key, value) pair into the %multimap.
00401        *  Contrary to a std::map the %multimap does not rely on unique keys and
00402        *  thus multiple pairs with the same key can be inserted.
00403        *
00404        *  Insertion requires logarithmic time.
00405        */
00406       iterator
00407       insert(const value_type& __x)
00408       { return _M_t._M_insert_equal(__x); }
00409 
00410       /**
00411        *  @brief Inserts a std::pair into the %multimap.
00412        *  @param  position  An iterator that serves as a hint as to where the
00413        *                    pair should be inserted.
00414        *  @param  x  Pair to be inserted (see std::make_pair for easy creation
00415        *             of pairs).
00416        *  @return An iterator that points to the inserted (key,value) pair.
00417        *
00418        *  This function inserts a (key, value) pair into the %multimap.
00419        *  Contrary to a std::map the %multimap does not rely on unique keys and
00420        *  thus multiple pairs with the same key can be inserted.
00421        *  Note that the first parameter is only a hint and can potentially
00422        *  improve the performance of the insertion process.  A bad hint would
00423        *  cause no gains in efficiency.
00424        *
00425        *  See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
00426        *  for more on "hinting".
00427        *
00428        *  Insertion requires logarithmic time (if the hint is not taken).
00429        */
00430       iterator
00431       insert(iterator __position, const value_type& __x)
00432       { return _M_t._M_insert_equal_(__position, __x); }
00433 
00434       /**
00435        *  @brief A template function that attempts to insert a range of elements.
00436        *  @param  first  Iterator pointing to the start of the range to be
00437        *                 inserted.
00438        *  @param  last  Iterator pointing to the end of the range.
00439        *
00440        *  Complexity similar to that of the range constructor.
00441        */
00442       template<typename _InputIterator>
00443         void
00444         insert(_InputIterator __first, _InputIterator __last)
00445         { _M_t._M_insert_equal(__first, __last); }
00446 
00447       /**
00448        *  @brief Erases an element from a %multimap.
00449        *  @param  position  An iterator pointing to the element to be erased.
00450        *
00451        *  This function erases an element, pointed to by the given iterator,
00452        *  from a %multimap.  Note that this function only erases the element,
00453        *  and that if the element is itself a pointer, the pointed-to memory is
00454        *  not touched in any way.  Managing the pointer is the user's
00455        *  responsibility.
00456        */
00457       void
00458       erase(iterator __position)
00459       { _M_t.erase(__position); }
00460 
00461       /**
00462        *  @brief Erases elements according to the provided key.
00463        *  @param  x  Key of element to be erased.
00464        *  @return  The number of elements erased.
00465        *
00466        *  This function erases all elements located by the given key from a
00467        *  %multimap.
00468        *  Note that this function only erases the element, and that if
00469        *  the element is itself a pointer, the pointed-to memory is not touched
00470        *  in any way.  Managing the pointer is the user's responsibility.
00471        */
00472       size_type
00473       erase(const key_type& __x)
00474       { return _M_t.erase(__x); }
00475 
00476       /**
00477        *  @brief Erases a [first,last) range of elements from a %multimap.
00478        *  @param  first  Iterator pointing to the start of the range to be
00479        *                 erased.
00480        *  @param  last  Iterator pointing to the end of the range to be erased.
00481        *
00482        *  This function erases a sequence of elements from a %multimap.
00483        *  Note that this function only erases the elements, and that if
00484        *  the elements themselves are pointers, the pointed-to memory is not
00485        *  touched in any way.  Managing the pointer is the user's responsibility.
00486        */
00487       void
00488       erase(iterator __first, iterator __last)
00489       { _M_t.erase(__first, __last); }
00490 
00491       /**
00492        *  @brief  Swaps data with another %multimap.
00493        *  @param  x  A %multimap of the same element and allocator types.
00494        *
00495        *  This exchanges the elements between two multimaps in constant time.
00496        *  (It is only swapping a pointer, an integer, and an instance of
00497        *  the @c Compare type (which itself is often stateless and empty), so it
00498        *  should be quite fast.)
00499        *  Note that the global std::swap() function is specialized such that
00500        *  std::swap(m1,m2) will feed to this function.
00501        */
00502       void
00503 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00504       swap(multimap&& __x)
00505 #else
00506       swap(multimap& __x)
00507 #endif
00508       { _M_t.swap(__x._M_t); }
00509 
00510       /**
00511        *  Erases all elements in a %multimap.  Note that this function only
00512        *  erases the elements, and that if the elements themselves are pointers,
00513        *  the pointed-to memory is not touched in any way.  Managing the pointer
00514        *  is the user's responsibility.
00515        */
00516       void
00517       clear()
00518       { _M_t.clear(); }
00519 
00520       // observers
00521       /**
00522        *  Returns the key comparison object out of which the %multimap
00523        *  was constructed.
00524        */
00525       key_compare
00526       key_comp() const
00527       { return _M_t.key_comp(); }
00528 
00529       /**
00530        *  Returns a value comparison object, built from the key comparison
00531        *  object out of which the %multimap was constructed.
00532        */
00533       value_compare
00534       value_comp() const
00535       { return value_compare(_M_t.key_comp()); }
00536 
00537       // multimap operations
00538       /**
00539        *  @brief Tries to locate an element in a %multimap.
00540        *  @param  x  Key of (key, value) pair to be located.
00541        *  @return  Iterator pointing to sought-after element,
00542        *           or end() if not found.
00543        *
00544        *  This function takes a key and tries to locate the element with which
00545        *  the key matches.  If successful the function returns an iterator
00546        *  pointing to the sought after %pair.  If unsuccessful it returns the
00547        *  past-the-end ( @c end() ) iterator.
00548        */
00549       iterator
00550       find(const key_type& __x)
00551       { return _M_t.find(__x); }
00552 
00553       /**
00554        *  @brief Tries to locate an element in a %multimap.
00555        *  @param  x  Key of (key, value) pair to be located.
00556        *  @return  Read-only (constant) iterator pointing to sought-after
00557        *           element, or end() if not found.
00558        *
00559        *  This function takes a key and tries to locate the element with which
00560        *  the key matches.  If successful the function returns a constant
00561        *  iterator pointing to the sought after %pair.  If unsuccessful it
00562        *  returns the past-the-end ( @c end() ) iterator.
00563        */
00564       const_iterator
00565       find(const key_type& __x) const
00566       { return _M_t.find(__x); }
00567 
00568       /**
00569        *  @brief Finds the number of elements with given key.
00570        *  @param  x  Key of (key, value) pairs to be located.
00571        *  @return Number of elements with specified key.
00572        */
00573       size_type
00574       count(const key_type& __x) const
00575       { return _M_t.count(__x); }
00576 
00577       /**
00578        *  @brief Finds the beginning of a subsequence matching given key.
00579        *  @param  x  Key of (key, value) pair to be located.
00580        *  @return  Iterator pointing to first element equal to or greater
00581        *           than key, or end().
00582        *
00583        *  This function returns the first element of a subsequence of elements
00584        *  that matches the given key.  If unsuccessful it returns an iterator
00585        *  pointing to the first element that has a greater value than given key
00586        *  or end() if no such element exists.
00587        */
00588       iterator
00589       lower_bound(const key_type& __x)
00590       { return _M_t.lower_bound(__x); }
00591 
00592       /**
00593        *  @brief Finds the beginning of a subsequence matching given key.
00594        *  @param  x  Key of (key, value) pair to be located.
00595        *  @return  Read-only (constant) iterator pointing to first element
00596        *           equal to or greater than key, or end().
00597        *
00598        *  This function returns the first element of a subsequence of elements
00599        *  that matches the given key.  If unsuccessful the iterator will point
00600        *  to the next greatest element or, if no such greater element exists, to
00601        *  end().
00602        */
00603       const_iterator
00604       lower_bound(const key_type& __x) const
00605       { return _M_t.lower_bound(__x); }
00606 
00607       /**
00608        *  @brief Finds the end of a subsequence matching given key.
00609        *  @param  x  Key of (key, value) pair to be located.
00610        *  @return Iterator pointing to the first element
00611        *          greater than key, or end().
00612        */
00613       iterator
00614       upper_bound(const key_type& __x)
00615       { return _M_t.upper_bound(__x); }
00616 
00617       /**
00618        *  @brief Finds the end of a subsequence matching given key.
00619        *  @param  x  Key of (key, value) pair to be located.
00620        *  @return  Read-only (constant) iterator pointing to first iterator
00621        *           greater than key, or end().
00622        */
00623       const_iterator
00624       upper_bound(const key_type& __x) const
00625       { return _M_t.upper_bound(__x); }
00626 
00627       /**
00628        *  @brief Finds a subsequence matching given key.
00629        *  @param  x  Key of (key, value) pairs to be located.
00630        *  @return  Pair of iterators that possibly points to the subsequence
00631        *           matching given key.
00632        *
00633        *  This function is equivalent to
00634        *  @code
00635        *    std::make_pair(c.lower_bound(val),
00636        *                   c.upper_bound(val))
00637        *  @endcode
00638        *  (but is faster than making the calls separately).
00639        */
00640       std::pair<iterator, iterator>
00641       equal_range(const key_type& __x)
00642       { return _M_t.equal_range(__x); }
00643 
00644       /**
00645        *  @brief Finds a subsequence matching given key.
00646        *  @param  x  Key of (key, value) pairs to be located.
00647        *  @return  Pair of read-only (constant) iterators that possibly points
00648        *           to the subsequence matching given key.
00649        *
00650        *  This function is equivalent to
00651        *  @code
00652        *    std::make_pair(c.lower_bound(val),
00653        *                   c.upper_bound(val))
00654        *  @endcode
00655        *  (but is faster than making the calls separately).
00656        */
00657       std::pair<const_iterator, const_iterator>
00658       equal_range(const key_type& __x) const
00659       { return _M_t.equal_range(__x); }
00660 
00661       template<typename _K1, typename _T1, typename _C1, typename _A1>
00662         friend bool
00663         operator==(const multimap<_K1, _T1, _C1, _A1>&,
00664            const multimap<_K1, _T1, _C1, _A1>&);
00665 
00666       template<typename _K1, typename _T1, typename _C1, typename _A1>
00667         friend bool
00668         operator<(const multimap<_K1, _T1, _C1, _A1>&,
00669           const multimap<_K1, _T1, _C1, _A1>&);
00670   };
00671 
00672   /**
00673    *  @brief  Multimap equality comparison.
00674    *  @param  x  A %multimap.
00675    *  @param  y  A %multimap of the same type as @a x.
00676    *  @return  True iff the size and elements of the maps are equal.
00677    *
00678    *  This is an equivalence relation.  It is linear in the size of the
00679    *  multimaps.  Multimaps are considered equivalent if their sizes are equal,
00680    *  and if corresponding elements compare equal.
00681   */
00682   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00683     inline bool
00684     operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00685                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00686     { return __x._M_t == __y._M_t; }
00687 
00688   /**
00689    *  @brief  Multimap ordering relation.
00690    *  @param  x  A %multimap.
00691    *  @param  y  A %multimap of the same type as @a x.
00692    *  @return  True iff @a x is lexicographically less than @a y.
00693    *
00694    *  This is a total ordering relation.  It is linear in the size of the
00695    *  multimaps.  The elements must be comparable with @c <.
00696    *
00697    *  See std::lexicographical_compare() for how the determination is made.
00698   */
00699   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00700     inline bool
00701     operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00702               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00703     { return __x._M_t < __y._M_t; }
00704 
00705   /// Based on operator==
00706   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00707     inline bool
00708     operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00709                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00710     { return !(__x == __y); }
00711 
00712   /// Based on operator<
00713   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00714     inline bool
00715     operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00716               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00717     { return __y < __x; }
00718 
00719   /// Based on operator<
00720   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00721     inline bool
00722     operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00723                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00724     { return !(__y < __x); }
00725 
00726   /// Based on operator<
00727   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00728     inline bool
00729     operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00730                const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00731     { return !(__x < __y); }
00732 
00733   /// See std::multimap::swap().
00734   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00735     inline void
00736     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00737          multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00738     { __x.swap(__y); }
00739 
00740 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00741   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00742     inline void
00743     swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
00744          multimap<_Key, _Tp, _Compare, _Alloc>& __y)
00745     { __x.swap(__y); }
00746 
00747   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00748     inline void
00749     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
00750          multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
00751     { __x.swap(__y); }
00752 #endif
00753 
00754 _GLIBCXX_END_NESTED_NAMESPACE
00755 
00756 #endif /* _STL_MULTIMAP_H */

Generated on Wed Mar 26 00:43:14 2008 for libstdc++ by  doxygen 1.5.1