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