# stl_set.h

Go to the documentation of this file.

    00001 // Set 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_set.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_SET_H
    00063 #define _STL_SET_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 unique keys, which can be
    00071    *  retrieved 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 unique keys).
    00079    *
    00080    *  Sets support bidirectional iterators.
    00081    *
    00082    *  @param  Key  Type of key objects.
    00083    *  @param  Compare  Comparison function object type, defaults to less<Key>.
    00084    *  @param  Alloc  Allocator type, defaults to allocator<Key>.
    00085    *
    00086    *  The private tree data is declared exactly the same way for set and
    00087    *  multiset; the distinction is made entirely in how the tree functions are
    00088    *  called (*_unique versus *_equal, same as the standard).
    00089   */
    00090   template<typename _Key, typename _Compare = std::less<_Key>,
    00091        typename _Alloc = std::allocator<_Key> >
    00092     class set
    00093     {
    00094       // concept requirements
    00095       typedef typename _Alloc::value_type                   _Alloc_value_type;
    00096       __glibcxx_class_requires(_Key, _SGIAssignableConcept)
    00097       __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
    00098                 _BinaryFunctionConcept)
    00099       __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
    00100
    00101     public:
    00102       // typedefs:
    00103       //@{
    00104       /// Public typedefs.
    00105       typedef _Key     key_type;
    00106       typedef _Key     value_type;
    00107       typedef _Compare key_compare;
    00108       typedef _Compare value_compare;
    00109       typedef _Alloc   allocator_type;
    00110       //@}
    00111
    00112     private:
    00113       typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
    00114
    00115       typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
    00116                key_compare, _Key_alloc_type> _Rep_type;
    00117       _Rep_type _M_t;  // Red-black tree representing set.
    00118
    00119     public:
    00120       //@{
    00121       ///  Iterator-related typedefs.
    00122       typedef typename _Key_alloc_type::pointer             pointer;
    00123       typedef typename _Key_alloc_type::const_pointer       const_pointer;
    00124       typedef typename _Key_alloc_type::reference           reference;
    00125       typedef typename _Key_alloc_type::const_reference     const_reference;
    00126       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00127       // DR 103. set::iterator is required to be modifiable,
    00128       // but this allows modification of keys.
    00129       typedef typename _Rep_type::const_iterator            iterator;
    00130       typedef typename _Rep_type::const_iterator            const_iterator;
    00131       typedef typename _Rep_type::const_reverse_iterator    reverse_iterator;
    00132       typedef typename _Rep_type::const_reverse_iterator    const_reverse_iterator;
    00133       typedef typename _Rep_type::size_type                 size_type;
    00134       typedef typename _Rep_type::difference_type           difference_type;
    00135       //@}
    00136
    00137       // allocation/deallocation
    00138       /**
    00139        *  @brief  Default constructor creates no elements.
    00140        */
    00141       set()
    00142       : _M_t() { }
    00143
    00144       /**
    00145        *  @brief  Creates a %set with no elements.
    00146        *  @param  comp  Comparator to use.
    00147        *  @param  a  An allocator object.
    00148        */
    00149       explicit
    00150       set(const _Compare& __comp,
    00151       const allocator_type& __a = allocator_type())
    00152       : _M_t(__comp, __a) { }
    00153
    00154       /**
    00155        *  @brief  Builds a %set from a range.
    00156        *  @param  first  An input iterator.
    00157        *  @param  last  An input iterator.
    00158        *
    00159        *  Create a %set consisting of copies of the elements from [first,last).
    00160        *  This is linear in N if the range is already sorted, and NlogN
    00161        *  otherwise (where N is distance(first,last)).
    00162        */
    00163       template<typename _InputIterator>
    00164         set(_InputIterator __first, _InputIterator __last)
    00165     : _M_t()
    00166         { _M_t._M_insert_unique(__first, __last); }
    00167
    00168       /**
    00169        *  @brief  Builds a %set from a range.
    00170        *  @param  first  An input iterator.
    00171        *  @param  last  An input iterator.
    00172        *  @param  comp  A comparison functor.
    00173        *  @param  a  An allocator object.
    00174        *
    00175        *  Create a %set consisting of copies of the elements from [first,last).
    00176        *  This is linear in N if the range is already sorted, and NlogN
    00177        *  otherwise (where N is distance(first,last)).
    00178        */
    00179       template<typename _InputIterator>
    00180         set(_InputIterator __first, _InputIterator __last,
    00181         const _Compare& __comp,
    00182         const allocator_type& __a = allocator_type())
    00183     : _M_t(__comp, __a)
    00184         { _M_t._M_insert_unique(__first, __last); }
    00185
    00186       /**
    00187        *  @brief  %Set copy constructor.
    00188        *  @param  x  A %set of identical element and allocator types.
    00189        *
    00190        *  The newly-created %set uses a copy of the allocation object used
    00191        *  by @a x.
    00192        */
    00193       set(const set& __x)
    00194       : _M_t(__x._M_t) { }
    00195
    00196 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    00197      /**
    00198        *  @brief %Set move constructor
    00199        *  @param x  A %set of identical element and allocator types.
    00200        *
    00201        *  The newly-created %set contains the exact contents of @a x.
    00202        *  The contents of @a x are a valid, but unspecified %set.
    00203        */
    00204       set(set&& __x)
    00205       : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
    00206 #endif
    00207
    00208       /**
    00209        *  @brief  %Set assignment operator.
    00210        *  @param  x  A %set of identical element and allocator types.
    00211        *
    00212        *  All the elements of @a x are copied, but unlike the copy constructor,
    00213        *  the allocator object is not copied.
    00214        */
    00215       set&
    00216       operator=(const set& __x)
    00217       {
    00218     _M_t = __x._M_t;
    00219     return *this;
    00220       }
    00221
    00222 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    00223       /**
    00224        *  @brief %Set move assignment operator.
    00225        *  @param x  A %set of identical element and allocator types.
    00226        *
    00227        *  The contents of @a x are moved into this %set (without copying).
    00228        *  @a x is a valid, but unspecified %set.
    00229        */
    00230       set&
    00231       operator=(set&& __x)
    00232       {
    00233     // NB: DR 675.
    00234     this->clear();
    00235     this->swap(__x);
    00236     return *this;
    00237       }
    00238 #endif
    00239
    00240       // accessors:
    00241
    00242       ///  Returns the comparison object with which the %set was constructed.
    00243       key_compare
    00244       key_comp() const
    00245       { return _M_t.key_comp(); }
    00246       ///  Returns the comparison object with which the %set was constructed.
    00247       value_compare
    00248       value_comp() const
    00249       { return _M_t.key_comp(); }
    00250       ///  Returns the allocator object with which the %set was constructed.
    00251       allocator_type
    00252       get_allocator() const
    00253       { return _M_t.get_allocator(); }
    00254
    00255       /**
    00256        *  Returns a read-only (constant) iterator that points to the first
    00257        *  element in the %set.  Iteration is done in ascending order according
    00258        *  to the keys.
    00259        */
    00260       iterator
    00261       begin() const
    00262       { return _M_t.begin(); }
    00263
    00264       /**
    00265        *  Returns a read-only (constant) iterator that points one past the last
    00266        *  element in the %set.  Iteration is done in ascending order according
    00267        *  to the keys.
    00268        */
    00269       iterator
    00270       end() const
    00271       { return _M_t.end(); }
    00272
    00273       /**
    00274        *  Returns a read-only (constant) iterator that points to the last
    00275        *  element in the %set.  Iteration is done in descending order according
    00276        *  to the keys.
    00277        */
    00278       reverse_iterator
    00279       rbegin() const
    00280       { return _M_t.rbegin(); }
    00281
    00282       /**
    00283        *  Returns a read-only (constant) reverse iterator that points to the
    00284        *  last pair in the %set.  Iteration is done in descending order
    00285        *  according to the keys.
    00286        */
    00287       reverse_iterator
    00288       rend() const
    00289       { return _M_t.rend(); }
    00290
    00291 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    00292       /**
    00293        *  Returns a read-only (constant) iterator that points to the first
    00294        *  element in the %set.  Iteration is done in ascending order according
    00295        *  to the keys.
    00296        */
    00297       iterator
    00298       cbegin() const
    00299       { return _M_t.begin(); }
    00300
    00301       /**
    00302        *  Returns a read-only (constant) iterator that points one past the last
    00303        *  element in the %set.  Iteration is done in ascending order according
    00304        *  to the keys.
    00305        */
    00306       iterator
    00307       cend() const
    00308       { return _M_t.end(); }
    00309
    00310       /**
    00311        *  Returns a read-only (constant) iterator that points to the last
    00312        *  element in the %set.  Iteration is done in descending order according
    00313        *  to the keys.
    00314        */
    00315       reverse_iterator
    00316       crbegin() const
    00317       { return _M_t.rbegin(); }
    00318
    00319       /**
    00320        *  Returns a read-only (constant) reverse iterator that points to the
    00321        *  last pair in the %set.  Iteration is done in descending order
    00322        *  according to the keys.
    00323        */
    00324       reverse_iterator
    00325       crend() const
    00326       { return _M_t.rend(); }
    00327 #endif
    00328
    00329       ///  Returns true if the %set is empty.
    00330       bool
    00331       empty() const
    00332       { return _M_t.empty(); }
    00333
    00334       ///  Returns the size of the %set.
    00335       size_type
    00336       size() const
    00337       { return _M_t.size(); }
    00338
    00339       ///  Returns the maximum size of the %set.
    00340       size_type
    00341       max_size() const
    00342       { return _M_t.max_size(); }
    00343
    00344       /**
    00345        *  @brief  Swaps data with another %set.
    00346        *  @param  x  A %set of the same element and allocator types.
    00347        *
    00348        *  This exchanges the elements between two sets in constant time.
    00349        *  (It is only swapping a pointer, an integer, and an instance of
    00350        *  the @c Compare type (which itself is often stateless and empty), so it
    00351        *  should be quite fast.)
    00352        *  Note that the global std::swap() function is specialized such that
    00353        *  std::swap(s1,s2) will feed to this function.
    00354        */
    00355       void
    00356 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    00357       swap(set&& __x)
    00358 #else
    00359       swap(set& __x)
    00360 #endif
    00361       { _M_t.swap(__x._M_t); }
    00362
    00363       // insert/erase
    00364       /**
    00365        *  @brief Attempts to insert an element into the %set.
    00366        *  @param  x  Element to be inserted.
    00367        *  @return  A pair, of which the first element is an iterator that points
    00368        *           to the possibly inserted element, and the second is a bool
    00369        *           that is true if the element was actually inserted.
    00370        *
    00371        *  This function attempts to insert an element into the %set.  A %set
    00372        *  relies on unique keys and thus an element is only inserted if it is
    00373        *  not already present in the %set.
    00374        *
    00375        *  Insertion requires logarithmic time.
    00376        */
    00377       std::pair<iterator, bool>
    00378       insert(const value_type& __x)
    00379       {
    00380     std::pair<typename _Rep_type::iterator, bool> __p =
    00381       _M_t._M_insert_unique(__x);
    00382     return std::pair<iterator, bool>(__p.first, __p.second);
    00383       }
    00384
    00385       /**
    00386        *  @brief Attempts to insert an element into the %set.
    00387        *  @param  position  An iterator that serves as a hint as to where the
    00388        *                    element should be inserted.
    00389        *  @param  x  Element to be inserted.
    00390        *  @return  An iterator that points to the element with key of @a x (may
    00391        *           or may not be the element passed in).
    00392        *
    00393        *  This function is not concerned about whether the insertion took place,
    00394        *  and thus does not return a boolean like the single-argument insert()
    00395        *  does.  Note that the first parameter is only a hint and can
    00396        *  potentially improve the performance of the insertion process.  A bad
    00397        *  hint would cause no gains in efficiency.
    00398        *
    00399        *  See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
    00400        *  for more on "hinting".
    00401        *
    00402        *  Insertion requires logarithmic time (if the hint is not taken).
    00403        */
    00404       iterator
    00405       insert(iterator __position, const value_type& __x)
    00406       { return _M_t._M_insert_unique_(__position, __x); }
    00407
    00408       /**
    00409        *  @brief A template function that attempts to insert a range of elements.
    00410        *  @param  first  Iterator pointing to the start of the range to be
    00411        *                 inserted.
    00412        *  @param  last  Iterator pointing to the end of the range.
    00413        *
    00414        *  Complexity similar to that of the range constructor.
    00415        */
    00416       template<typename _InputIterator>
    00417         void
    00418         insert(_InputIterator __first, _InputIterator __last)
    00419         { _M_t._M_insert_unique(__first, __last); }
    00420
    00421       /**
    00422        *  @brief Erases an element from a %set.
    00423        *  @param  position  An iterator pointing to the element to be erased.
    00424        *
    00425        *  This function erases an element, pointed to by the given iterator,
    00426        *  from a %set.  Note that this function only erases the element, and
    00427        *  that if the element is itself a pointer, the pointed-to memory is not
    00428        *  touched in any way.  Managing the pointer is the user's responsibility.
    00429        */
    00430       void
    00431       erase(iterator __position)
    00432       { _M_t.erase(__position); }
    00433
    00434       /**
    00435        *  @brief Erases elements according to the provided key.
    00436        *  @param  x  Key of element to be erased.
    00437        *  @return  The number of elements erased.
    00438        *
    00439        *  This function erases all the elements located by the given key from
    00440        *  a %set.
    00441        *  Note that this function only erases the element, and that if
    00442        *  the element is itself a pointer, the pointed-to memory is not touched
    00443        *  in any way.  Managing the pointer is the user's responsibility.
    00444        */
    00445       size_type
    00446       erase(const key_type& __x)
    00447       { return _M_t.erase(__x); }
    00448
    00449       /**
    00450        *  @brief Erases a [first,last) range of elements from a %set.
    00451        *  @param  first  Iterator pointing to the start of the range to be
    00452        *                 erased.
    00453        *  @param  last  Iterator pointing to the end of the range to be erased.
    00454        *
    00455        *  This function erases a sequence of elements from a %set.
    00456        *  Note that this function only erases the element, and that if
    00457        *  the element is itself a pointer, the pointed-to memory is not touched
    00458        *  in any way.  Managing the pointer is the user's responsibility.
    00459        */
    00460       void
    00461       erase(iterator __first, iterator __last)
    00462       { _M_t.erase(__first, __last); }
    00463
    00464       /**
    00465        *  Erases all elements in a %set.  Note that this function only erases
    00466        *  the elements, and that if the elements themselves are pointers, the
    00467        *  pointed-to memory is not touched in any way.  Managing the pointer is
    00468        *  the user's responsibility.
    00469        */
    00470       void
    00471       clear()
    00472       { _M_t.clear(); }
    00473
    00474       // set operations:
    00475
    00476       /**
    00477        *  @brief  Finds the number of elements.
    00478        *  @param  x  Element to located.
    00479        *  @return  Number of elements with specified key.
    00480        *
    00481        *  This function only makes sense for multisets; for set the result will
    00482        *  either be 0 (not present) or 1 (present).
    00483        */
    00484       size_type
    00485       count(const key_type& __x) const
    00486       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
    00487
    00488       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00489       // 214.  set::find() missing const overload
    00490       //@{
    00491       /**
    00492        *  @brief Tries to locate an element in a %set.
    00493        *  @param  x  Element to be located.
    00494        *  @return  Iterator pointing to sought-after element, or end() if not
    00495        *           found.
    00496        *
    00497        *  This function takes a key and tries to locate the element with which
    00498        *  the key matches.  If successful the function returns an iterator
    00499        *  pointing to the sought after element.  If unsuccessful it returns the
    00500        *  past-the-end ( @c end() ) iterator.
    00501        */
    00502       iterator
    00503       find(const key_type& __x)
    00504       { return _M_t.find(__x); }
    00505
    00506       const_iterator
    00507       find(const key_type& __x) const
    00508       { return _M_t.find(__x); }
    00509       //@}
    00510
    00511       //@{
    00512       /**
    00513        *  @brief Finds the beginning of a subsequence matching given key.
    00514        *  @param  x  Key to be located.
    00515        *  @return  Iterator pointing to first element equal to or greater
    00516        *           than key, or end().
    00517        *
    00518        *  This function returns the first element of a subsequence of elements
    00519        *  that matches the given key.  If unsuccessful it returns an iterator
    00520        *  pointing to the first element that has a greater value than given key
    00521        *  or end() if no such element exists.
    00522        */
    00523       iterator
    00524       lower_bound(const key_type& __x)
    00525       { return _M_t.lower_bound(__x); }
    00526
    00527       const_iterator
    00528       lower_bound(const key_type& __x) const
    00529       { return _M_t.lower_bound(__x); }
    00530       //@}
    00531
    00532       //@{
    00533       /**
    00534        *  @brief Finds the end of a subsequence matching given key.
    00535        *  @param  x  Key to be located.
    00536        *  @return Iterator pointing to the first element
    00537        *          greater than key, or end().
    00538        */
    00539       iterator
    00540       upper_bound(const key_type& __x)
    00541       { return _M_t.upper_bound(__x); }
    00542
    00543       const_iterator
    00544       upper_bound(const key_type& __x) const
    00545       { return _M_t.upper_bound(__x); }
    00546       //@}
    00547
    00548       //@{
    00549       /**
    00550        *  @brief Finds a subsequence matching given key.
    00551        *  @param  x  Key to be located.
    00552        *  @return  Pair of iterators that possibly points to the subsequence
    00553        *           matching given key.
    00554        *
    00555        *  This function is equivalent to
    00556        *  @code
    00557        *    std::make_pair(c.lower_bound(val),
    00558        *                   c.upper_bound(val))
    00559        *  @endcode
    00560        *  (but is faster than making the calls separately).
    00561        *
    00562        *  This function probably only makes sense for multisets.
    00563        */
    00564       std::pair<iterator, iterator>
    00565       equal_range(const key_type& __x)
    00566       { return _M_t.equal_range(__x); }
    00567
    00568       std::pair<const_iterator, const_iterator>
    00569       equal_range(const key_type& __x) const
    00570       { return _M_t.equal_range(__x); }
    00571       //@}
    00572
    00573       template<typename _K1, typename _C1, typename _A1>
    00574         friend bool
    00575         operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
    00576
    00577       template<typename _K1, typename _C1, typename _A1>
    00578         friend bool
    00579         operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
    00580     };
    00581
    00582
    00583   /**
    00584    *  @brief  Set equality comparison.
    00585    *  @param  x  A %set.
    00586    *  @param  y  A %set of the same type as @a x.
    00587    *  @return  True iff the size and elements of the sets are equal.
    00588    *
    00589    *  This is an equivalence relation.  It is linear in the size of the sets.
    00590    *  Sets are considered equivalent if their sizes are equal, and if
    00591    *  corresponding elements compare equal.
    00592   */
    00593   template<typename _Key, typename _Compare, typename _Alloc>
    00594     inline bool
    00595     operator==(const set<_Key, _Compare, _Alloc>& __x,
    00596            const set<_Key, _Compare, _Alloc>& __y)
    00597     { return __x._M_t == __y._M_t; }
    00598
    00599   /**
    00600    *  @brief  Set ordering relation.
    00601    *  @param  x  A %set.
    00602    *  @param  y  A %set of the same type as @a x.
    00603    *  @return  True iff @a x is lexicographically less than @a y.
    00604    *
    00605    *  This is a total ordering relation.  It is linear in the size of the
    00606    *  maps.  The elements must be comparable with @c <.
    00607    *
    00608    *  See std::lexicographical_compare() for how the determination is made.
    00609   */
    00610   template<typename _Key, typename _Compare, typename _Alloc>
    00611     inline bool
    00612     operator<(const set<_Key, _Compare, _Alloc>& __x,
    00613           const set<_Key, _Compare, _Alloc>& __y)
    00614     { return __x._M_t < __y._M_t; }
    00615
    00616   ///  Returns !(x == y).
    00617   template<typename _Key, typename _Compare, typename _Alloc>
    00618     inline bool
    00619     operator!=(const set<_Key, _Compare, _Alloc>& __x,
    00620            const set<_Key, _Compare, _Alloc>& __y)
    00621     { return !(__x == __y); }
    00622
    00623   ///  Returns y < x.
    00624   template<typename _Key, typename _Compare, typename _Alloc>
    00625     inline bool
    00626     operator>(const set<_Key, _Compare, _Alloc>& __x,
    00627           const set<_Key, _Compare, _Alloc>& __y)
    00628     { return __y < __x; }
    00629
    00630   ///  Returns !(y < x)
    00631   template<typename _Key, typename _Compare, typename _Alloc>
    00632     inline bool
    00633     operator<=(const set<_Key, _Compare, _Alloc>& __x,
    00634            const set<_Key, _Compare, _Alloc>& __y)
    00635     { return !(__y < __x); }
    00636
    00637   ///  Returns !(x < y)
    00638   template<typename _Key, typename _Compare, typename _Alloc>
    00639     inline bool
    00640     operator>=(const set<_Key, _Compare, _Alloc>& __x,
    00641            const set<_Key, _Compare, _Alloc>& __y)
    00642     { return !(__x < __y); }
    00643
    00644   /// See std::set::swap().
    00645   template<typename _Key, typename _Compare, typename _Alloc>
    00646     inline void
    00647     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
    00648     { __x.swap(__y); }
    00649
    00650 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    00651   template<typename _Key, typename _Compare, typename _Alloc>
    00652     inline void
    00653     swap(set<_Key, _Compare, _Alloc>&& __x, set<_Key, _Compare, _Alloc>& __y)
    00654     { __x.swap(__y); }
    00655
    00656   template<typename _Key, typename _Compare, typename _Alloc>
    00657     inline void
    00658     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>&& __y)
    00659     { __x.swap(__y); }
    00660 #endif
    00661
    00662 _GLIBCXX_END_NESTED_NAMESPACE
    00663
    00664 #endif /* _STL_SET_H */