stl_multiset.h

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