OSDN Git Service

2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / stl_set.h
1 // Set implementation -*- C++ -*-
2
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
20
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 // <http://www.gnu.org/licenses/>.
25
26 /*
27  *
28  * Copyright (c) 1994
29  * Hewlett-Packard Company
30  *
31  * Permission to use, copy, modify, distribute and sell this software
32  * and its documentation for any purpose is hereby granted without fee,
33  * provided that the above copyright notice appear in all copies and
34  * that both that copyright notice and this permission notice appear
35  * in supporting documentation.  Hewlett-Packard Company makes no
36  * representations about the suitability of this software for any
37  * purpose.  It is provided "as is" without express or implied warranty.
38  *
39  *
40  * Copyright (c) 1996,1997
41  * Silicon Graphics Computer Systems, Inc.
42  *
43  * Permission to use, copy, modify, distribute and sell this software
44  * and its documentation for any purpose is hereby granted without fee,
45  * provided that the above copyright notice appear in all copies and
46  * that both that copyright notice and this permission notice appear
47  * in supporting documentation.  Silicon Graphics makes no
48  * representations about the suitability of this software for any
49  * purpose.  It is provided "as is" without express or implied warranty.
50  */
51
52 /** @file stl_set.h
53  *  This is an internal header file, included by other library headers.
54  *  You should not attempt to use it directly.
55  */
56
57 #ifndef _STL_SET_H
58 #define _STL_SET_H 1
59
60 #include <bits/concept_check.h>
61 #include <initializer_list>
62
63 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
64
65   /**
66    *  @brief A standard container made up of unique keys, which can be
67    *  retrieved in logarithmic time.
68    *
69    *  @ingroup associative_containers
70    *
71    *  Meets the requirements of a <a href="tables.html#65">container</a>, a
72    *  <a href="tables.html#66">reversible container</a>, and an
73    *  <a href="tables.html#69">associative container</a> (using unique keys).
74    *
75    *  Sets support bidirectional iterators.
76    *
77    *  @param  Key  Type of key objects.
78    *  @param  Compare  Comparison function object type, defaults to less<Key>.
79    *  @param  Alloc  Allocator type, defaults to allocator<Key>.
80    *
81    *  The private tree data is declared exactly the same way for set and
82    *  multiset; the distinction is made entirely in how the tree functions are
83    *  called (*_unique versus *_equal, same as the standard).
84   */
85   template<typename _Key, typename _Compare = std::less<_Key>,
86            typename _Alloc = std::allocator<_Key> >
87     class set
88     {
89       // concept requirements
90       typedef typename _Alloc::value_type                   _Alloc_value_type;
91       __glibcxx_class_requires(_Key, _SGIAssignableConcept)
92       __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
93                                 _BinaryFunctionConcept)
94       __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)      
95
96     public:
97       // typedefs:
98       //@{
99       /// Public typedefs.
100       typedef _Key     key_type;
101       typedef _Key     value_type;
102       typedef _Compare key_compare;
103       typedef _Compare value_compare;
104       typedef _Alloc   allocator_type;
105       //@}
106
107     private:
108       typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
109
110       typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
111                        key_compare, _Key_alloc_type> _Rep_type;
112       _Rep_type _M_t;  // Red-black tree representing set.
113
114     public:
115       //@{
116       ///  Iterator-related typedefs.
117       typedef typename _Key_alloc_type::pointer             pointer;
118       typedef typename _Key_alloc_type::const_pointer       const_pointer;
119       typedef typename _Key_alloc_type::reference           reference;
120       typedef typename _Key_alloc_type::const_reference     const_reference;
121       // _GLIBCXX_RESOLVE_LIB_DEFECTS
122       // DR 103. set::iterator is required to be modifiable,
123       // but this allows modification of keys.
124       typedef typename _Rep_type::const_iterator            iterator;
125       typedef typename _Rep_type::const_iterator            const_iterator;
126       typedef typename _Rep_type::const_reverse_iterator    reverse_iterator;
127       typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
128       typedef typename _Rep_type::size_type                 size_type;
129       typedef typename _Rep_type::difference_type           difference_type;
130       //@}
131
132       // allocation/deallocation
133       /**
134        *  @brief  Default constructor creates no elements.
135        */
136       set()
137       : _M_t() { }
138
139       /**
140        *  @brief  Creates a %set with no elements.
141        *  @param  comp  Comparator to use.
142        *  @param  a  An allocator object.
143        */
144       explicit
145       set(const _Compare& __comp,
146           const allocator_type& __a = allocator_type())
147       : _M_t(__comp, __a) { }
148
149       /**
150        *  @brief  Builds a %set from a range.
151        *  @param  first  An input iterator.
152        *  @param  last  An input iterator.
153        *
154        *  Create a %set consisting of copies of the elements from [first,last).
155        *  This is linear in N if the range is already sorted, and NlogN
156        *  otherwise (where N is distance(first,last)).
157        */
158       template<typename _InputIterator>
159         set(_InputIterator __first, _InputIterator __last)
160         : _M_t()
161         { _M_t._M_insert_unique(__first, __last); }
162
163       /**
164        *  @brief  Builds a %set from a range.
165        *  @param  first  An input iterator.
166        *  @param  last  An input iterator.
167        *  @param  comp  A comparison functor.
168        *  @param  a  An allocator object.
169        *
170        *  Create a %set consisting of copies of the elements from [first,last).
171        *  This is linear in N if the range is already sorted, and NlogN
172        *  otherwise (where N is distance(first,last)).
173        */
174       template<typename _InputIterator>
175         set(_InputIterator __first, _InputIterator __last,
176             const _Compare& __comp,
177             const allocator_type& __a = allocator_type())
178         : _M_t(__comp, __a)
179         { _M_t._M_insert_unique(__first, __last); }
180
181       /**
182        *  @brief  %Set copy constructor.
183        *  @param  x  A %set of identical element and allocator types.
184        *
185        *  The newly-created %set uses a copy of the allocation object used
186        *  by @a x.
187        */
188       set(const set& __x)
189       : _M_t(__x._M_t) { }
190
191 #ifdef __GXX_EXPERIMENTAL_CXX0X__
192      /**
193        *  @brief %Set move constructor
194        *  @param x  A %set of identical element and allocator types.
195        *
196        *  The newly-created %set contains the exact contents of @a x.
197        *  The contents of @a x are a valid, but unspecified %set.
198        */
199       set(set&& __x)
200       : _M_t(std::move(__x._M_t)) { }
201
202       /**
203        *  @brief  Builds a %set from an initializer_list.
204        *  @param  l  An initializer_list.
205        *  @param  comp  A comparison functor.
206        *  @param  a  An allocator object.
207        *
208        *  Create a %set consisting of copies of the elements in the list.
209        *  This is linear in N if the list is already sorted, and NlogN
210        *  otherwise (where N is @a l.size()).
211        */
212       set(initializer_list<value_type> __l,
213           const _Compare& __comp = _Compare(),
214           const allocator_type& __a = allocator_type())
215       : _M_t(__comp, __a)
216       { _M_t._M_insert_unique(__l.begin(), __l.end()); }
217 #endif
218
219       /**
220        *  @brief  %Set assignment operator.
221        *  @param  x  A %set of identical element and allocator types.
222        *
223        *  All the elements of @a x are copied, but unlike the copy constructor,
224        *  the allocator object is not copied.
225        */
226       set&
227       operator=(const set& __x)
228       {
229         _M_t = __x._M_t;
230         return *this;
231       }
232
233 #ifdef __GXX_EXPERIMENTAL_CXX0X__
234       /**
235        *  @brief %Set move assignment operator.
236        *  @param x  A %set of identical element and allocator types.
237        *
238        *  The contents of @a x are moved into this %set (without copying).
239        *  @a x is a valid, but unspecified %set.
240        */
241       set&
242       operator=(set&& __x)
243       {
244         // NB: DR 1204.
245         // NB: DR 675.
246         this->clear();
247         this->swap(__x);
248         return *this;
249       }
250
251       /**
252        *  @brief  %Set list assignment operator.
253        *  @param  l  An initializer_list.
254        *
255        *  This function fills a %set with copies of the elements in the
256        *  initializer list @a l.
257        *
258        *  Note that the assignment completely changes the %set and
259        *  that the resulting %set's size is the same as the number
260        *  of elements assigned.  Old data may be lost.
261        */
262       set&
263       operator=(initializer_list<value_type> __l)
264       {
265         this->clear();
266         this->insert(__l.begin(), __l.end());
267         return *this;
268       }
269 #endif
270
271       // accessors:
272
273       ///  Returns the comparison object with which the %set was constructed.
274       key_compare
275       key_comp() const
276       { return _M_t.key_comp(); }
277       ///  Returns the comparison object with which the %set was constructed.
278       value_compare
279       value_comp() const
280       { return _M_t.key_comp(); }
281       ///  Returns the allocator object with which the %set was constructed.
282       allocator_type
283       get_allocator() const
284       { return _M_t.get_allocator(); }
285
286       /**
287        *  Returns a read-only (constant) iterator that points to the first
288        *  element in the %set.  Iteration is done in ascending order according
289        *  to the keys.
290        */
291       iterator
292       begin() const
293       { return _M_t.begin(); }
294
295       /**
296        *  Returns a read-only (constant) iterator that points one past the last
297        *  element in the %set.  Iteration is done in ascending order according
298        *  to the keys.
299        */
300       iterator
301       end() const
302       { return _M_t.end(); }
303
304       /**
305        *  Returns a read-only (constant) iterator that points to the last
306        *  element in the %set.  Iteration is done in descending order according
307        *  to the keys.
308        */
309       reverse_iterator
310       rbegin() const
311       { return _M_t.rbegin(); }
312
313       /**
314        *  Returns a read-only (constant) reverse iterator that points to the
315        *  last pair in the %set.  Iteration is done in descending order
316        *  according to the keys.
317        */
318       reverse_iterator
319       rend() const
320       { return _M_t.rend(); }
321
322 #ifdef __GXX_EXPERIMENTAL_CXX0X__
323       /**
324        *  Returns a read-only (constant) iterator that points to the first
325        *  element in the %set.  Iteration is done in ascending order according
326        *  to the keys.
327        */
328       iterator
329       cbegin() const
330       { return _M_t.begin(); }
331
332       /**
333        *  Returns a read-only (constant) iterator that points one past the last
334        *  element in the %set.  Iteration is done in ascending order according
335        *  to the keys.
336        */
337       iterator
338       cend() const
339       { return _M_t.end(); }
340
341       /**
342        *  Returns a read-only (constant) iterator that points to the last
343        *  element in the %set.  Iteration is done in descending order according
344        *  to the keys.
345        */
346       reverse_iterator
347       crbegin() const
348       { return _M_t.rbegin(); }
349
350       /**
351        *  Returns a read-only (constant) reverse iterator that points to the
352        *  last pair in the %set.  Iteration is done in descending order
353        *  according to the keys.
354        */
355       reverse_iterator
356       crend() const
357       { return _M_t.rend(); }
358 #endif
359
360       ///  Returns true if the %set is empty.
361       bool
362       empty() const
363       { return _M_t.empty(); }
364
365       ///  Returns the size of the %set.
366       size_type
367       size() const
368       { return _M_t.size(); }
369
370       ///  Returns the maximum size of the %set.
371       size_type
372       max_size() const
373       { return _M_t.max_size(); }
374
375       /**
376        *  @brief  Swaps data with another %set.
377        *  @param  x  A %set of the same element and allocator types.
378        *
379        *  This exchanges the elements between two sets in constant time.
380        *  (It is only swapping a pointer, an integer, and an instance of
381        *  the @c Compare type (which itself is often stateless and empty), so it
382        *  should be quite fast.)
383        *  Note that the global std::swap() function is specialized such that
384        *  std::swap(s1,s2) will feed to this function.
385        */
386       void
387       swap(set& __x)    
388       { _M_t.swap(__x._M_t); }
389
390       // insert/erase
391       /**
392        *  @brief Attempts to insert an element into the %set.
393        *  @param  x  Element to be inserted.
394        *  @return  A pair, of which the first element is an iterator that points
395        *           to the possibly inserted element, and the second is a bool
396        *           that is true if the element was actually inserted.
397        *
398        *  This function attempts to insert an element into the %set.  A %set
399        *  relies on unique keys and thus an element is only inserted if it is
400        *  not already present in the %set.
401        *
402        *  Insertion requires logarithmic time.
403        */
404       std::pair<iterator, bool>
405       insert(const value_type& __x)
406       {
407         std::pair<typename _Rep_type::iterator, bool> __p =
408           _M_t._M_insert_unique(__x);
409         return std::pair<iterator, bool>(__p.first, __p.second);
410       }
411
412 #ifdef __GXX_EXPERIMENTAL_CXX0X__
413       std::pair<iterator, bool>
414       insert(value_type&& __x)
415       {
416         std::pair<typename _Rep_type::iterator, bool> __p =
417           _M_t._M_insert_unique(std::move(__x));
418         return std::pair<iterator, bool>(__p.first, __p.second);
419       }
420 #endif
421
422       /**
423        *  @brief Attempts to insert an element into the %set.
424        *  @param  position  An iterator that serves as a hint as to where the
425        *                    element should be inserted.
426        *  @param  x  Element to be inserted.
427        *  @return  An iterator that points to the element with key of @a x (may
428        *           or may not be the element passed in).
429        *
430        *  This function is not concerned about whether the insertion took place,
431        *  and thus does not return a boolean like the single-argument insert()
432        *  does.  Note that the first parameter is only a hint and can
433        *  potentially improve the performance of the insertion process.  A bad
434        *  hint would cause no gains in efficiency.
435        *
436        *  For more on @a hinting, see:
437        *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
438        *  
439        *  Insertion requires logarithmic time (if the hint is not taken).
440        */
441       iterator
442 #ifdef __GXX_EXPERIMENTAL_CXX0X__
443       insert(const_iterator __position, const value_type& __x)
444 #else
445       insert(iterator __position, const value_type& __x)
446 #endif
447       { return _M_t._M_insert_unique_(__position, __x); }
448
449 #ifdef __GXX_EXPERIMENTAL_CXX0X__
450       iterator
451       insert(const_iterator __position, value_type&& __x)
452       { return _M_t._M_insert_unique_(__position, std::move(__x)); }
453 #endif
454
455       /**
456        *  @brief A template function that attempts to insert a range
457        *  of elements.
458        *  @param  first  Iterator pointing to the start of the range to be
459        *                 inserted.
460        *  @param  last  Iterator pointing to the end of the range.
461        *
462        *  Complexity similar to that of the range constructor.
463        */
464       template<typename _InputIterator>
465         void
466         insert(_InputIterator __first, _InputIterator __last)
467         { _M_t._M_insert_unique(__first, __last); }
468
469 #ifdef __GXX_EXPERIMENTAL_CXX0X__
470       /**
471        *  @brief Attempts to insert a list of elements into the %set.
472        *  @param  list  A std::initializer_list<value_type> of elements
473        *                to be inserted.
474        *
475        *  Complexity similar to that of the range constructor.
476        */
477       void
478       insert(initializer_list<value_type> __l)
479       { this->insert(__l.begin(), __l.end()); }
480 #endif
481
482 #ifdef __GXX_EXPERIMENTAL_CXX0X__
483       // _GLIBCXX_RESOLVE_LIB_DEFECTS
484       // DR 130. Associative erase should return an iterator.
485       /**
486        *  @brief Erases an element from a %set.
487        *  @param  position  An iterator pointing to the element to be erased.
488        *  @return An iterator pointing to the element immediately following
489        *          @a position prior to the element being erased. If no such 
490        *          element exists, end() is returned.
491        *
492        *  This function erases an element, pointed to by the given iterator,
493        *  from a %set.  Note that this function only erases the element, and
494        *  that if the element is itself a pointer, the pointed-to memory is not
495        *  touched in any way.  Managing the pointer is the user's
496        *  responsibility.
497        */
498       iterator
499       erase(const_iterator __position)
500       { return _M_t.erase(__position); }
501 #else
502       /**
503        *  @brief Erases an element from a %set.
504        *  @param  position  An iterator pointing to the element to be erased.
505        *
506        *  This function erases an element, pointed to by the given iterator,
507        *  from a %set.  Note that this function only erases the element, and
508        *  that if the element is itself a pointer, the pointed-to memory is not
509        *  touched in any way.  Managing the pointer is the user's
510        *  responsibility.
511        */
512       void
513       erase(iterator __position)
514       { _M_t.erase(__position); }
515 #endif
516
517       /**
518        *  @brief Erases elements according to the provided key.
519        *  @param  x  Key of element to be erased.
520        *  @return  The number of elements erased.
521        *
522        *  This function erases all the elements located by the given key from
523        *  a %set.
524        *  Note that this function only erases the element, and that if
525        *  the element is itself a pointer, the pointed-to memory is not touched
526        *  in any way.  Managing the pointer is the user's responsibility.
527        */
528       size_type
529       erase(const key_type& __x)
530       { return _M_t.erase(__x); }
531
532 #ifdef __GXX_EXPERIMENTAL_CXX0X__
533       // _GLIBCXX_RESOLVE_LIB_DEFECTS
534       // DR 130. Associative erase should return an iterator.
535       /**
536        *  @brief Erases a [first,last) range of elements from a %set.
537        *  @param  first  Iterator pointing to the start of the range to be
538        *                 erased.
539        *  @param  last  Iterator pointing to the end of the range to be erased.
540        *  @return The iterator @a last.
541        *
542        *  This function erases a sequence of elements from a %set.
543        *  Note that this function only erases the element, and that if
544        *  the element is itself a pointer, the pointed-to memory is not touched
545        *  in any way.  Managing the pointer is the user's responsibility.
546        */
547       iterator
548       erase(const_iterator __first, const_iterator __last)
549       { return _M_t.erase(__first, __last); }
550 #else
551       /**
552        *  @brief Erases a [first,last) range of elements from a %set.
553        *  @param  first  Iterator pointing to the start of the range to be
554        *                 erased.
555        *  @param  last  Iterator pointing to the end of the range to be erased.
556        *
557        *  This function erases a sequence of elements from a %set.
558        *  Note that this function only erases the element, and that if
559        *  the element is itself a pointer, the pointed-to memory is not touched
560        *  in any way.  Managing the pointer is the user's responsibility.
561        */
562       void
563       erase(iterator __first, iterator __last)
564       { _M_t.erase(__first, __last); }
565 #endif
566
567       /**
568        *  Erases all elements in a %set.  Note that this function only erases
569        *  the elements, and that if the elements themselves are pointers, the
570        *  pointed-to memory is not touched in any way.  Managing the pointer is
571        *  the user's responsibility.
572        */
573       void
574       clear()
575       { _M_t.clear(); }
576
577       // set operations:
578
579       /**
580        *  @brief  Finds the number of elements.
581        *  @param  x  Element to located.
582        *  @return  Number of elements with specified key.
583        *
584        *  This function only makes sense for multisets; for set the result will
585        *  either be 0 (not present) or 1 (present).
586        */
587       size_type
588       count(const key_type& __x) const
589       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
590
591       // _GLIBCXX_RESOLVE_LIB_DEFECTS
592       // 214.  set::find() missing const overload
593       //@{
594       /**
595        *  @brief Tries to locate an element in a %set.
596        *  @param  x  Element to be located.
597        *  @return  Iterator pointing to sought-after element, or end() if not
598        *           found.
599        *
600        *  This function takes a key and tries to locate the element with which
601        *  the key matches.  If successful the function returns an iterator
602        *  pointing to the sought after element.  If unsuccessful it returns the
603        *  past-the-end ( @c end() ) iterator.
604        */
605       iterator
606       find(const key_type& __x)
607       { return _M_t.find(__x); }
608
609       const_iterator
610       find(const key_type& __x) const
611       { return _M_t.find(__x); }
612       //@}
613
614       //@{
615       /**
616        *  @brief Finds the beginning of a subsequence matching given key.
617        *  @param  x  Key to be located.
618        *  @return  Iterator pointing to first element equal to or greater
619        *           than key, or end().
620        *
621        *  This function returns the first element of a subsequence of elements
622        *  that matches the given key.  If unsuccessful it returns an iterator
623        *  pointing to the first element that has a greater value than given key
624        *  or end() if no such element exists.
625        */
626       iterator
627       lower_bound(const key_type& __x)
628       { return _M_t.lower_bound(__x); }
629
630       const_iterator
631       lower_bound(const key_type& __x) const
632       { return _M_t.lower_bound(__x); }
633       //@}
634
635       //@{
636       /**
637        *  @brief Finds the end of a subsequence matching given key.
638        *  @param  x  Key to be located.
639        *  @return Iterator pointing to the first element
640        *          greater than key, or end().
641        */
642       iterator
643       upper_bound(const key_type& __x)
644       { return _M_t.upper_bound(__x); }
645
646       const_iterator
647       upper_bound(const key_type& __x) const
648       { return _M_t.upper_bound(__x); }
649       //@}
650
651       //@{
652       /**
653        *  @brief Finds a subsequence matching given key.
654        *  @param  x  Key to be located.
655        *  @return  Pair of iterators that possibly points to the subsequence
656        *           matching given key.
657        *
658        *  This function is equivalent to
659        *  @code
660        *    std::make_pair(c.lower_bound(val),
661        *                   c.upper_bound(val))
662        *  @endcode
663        *  (but is faster than making the calls separately).
664        *
665        *  This function probably only makes sense for multisets.
666        */
667       std::pair<iterator, iterator>
668       equal_range(const key_type& __x)
669       { return _M_t.equal_range(__x); }
670
671       std::pair<const_iterator, const_iterator>
672       equal_range(const key_type& __x) const
673       { return _M_t.equal_range(__x); }
674       //@}
675
676       template<typename _K1, typename _C1, typename _A1>
677         friend bool
678         operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
679
680       template<typename _K1, typename _C1, typename _A1>
681         friend bool
682         operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
683     };
684
685
686   /**
687    *  @brief  Set equality comparison.
688    *  @param  x  A %set.
689    *  @param  y  A %set of the same type as @a x.
690    *  @return  True iff the size and elements of the sets are equal.
691    *
692    *  This is an equivalence relation.  It is linear in the size of the sets.
693    *  Sets are considered equivalent if their sizes are equal, and if
694    *  corresponding elements compare equal.
695   */
696   template<typename _Key, typename _Compare, typename _Alloc>
697     inline bool
698     operator==(const set<_Key, _Compare, _Alloc>& __x,
699                const set<_Key, _Compare, _Alloc>& __y)
700     { return __x._M_t == __y._M_t; }
701
702   /**
703    *  @brief  Set ordering relation.
704    *  @param  x  A %set.
705    *  @param  y  A %set of the same type as @a x.
706    *  @return  True iff @a x is lexicographically less than @a y.
707    *
708    *  This is a total ordering relation.  It is linear in the size of the
709    *  maps.  The elements must be comparable with @c <.
710    *
711    *  See std::lexicographical_compare() for how the determination is made.
712   */
713   template<typename _Key, typename _Compare, typename _Alloc>
714     inline bool
715     operator<(const set<_Key, _Compare, _Alloc>& __x,
716               const set<_Key, _Compare, _Alloc>& __y)
717     { return __x._M_t < __y._M_t; }
718
719   ///  Returns !(x == y).
720   template<typename _Key, typename _Compare, typename _Alloc>
721     inline bool
722     operator!=(const set<_Key, _Compare, _Alloc>& __x,
723                const set<_Key, _Compare, _Alloc>& __y)
724     { return !(__x == __y); }
725
726   ///  Returns y < x.
727   template<typename _Key, typename _Compare, typename _Alloc>
728     inline bool
729     operator>(const set<_Key, _Compare, _Alloc>& __x,
730               const set<_Key, _Compare, _Alloc>& __y)
731     { return __y < __x; }
732
733   ///  Returns !(y < x)
734   template<typename _Key, typename _Compare, typename _Alloc>
735     inline bool
736     operator<=(const set<_Key, _Compare, _Alloc>& __x,
737                const set<_Key, _Compare, _Alloc>& __y)
738     { return !(__y < __x); }
739
740   ///  Returns !(x < y)
741   template<typename _Key, typename _Compare, typename _Alloc>
742     inline bool
743     operator>=(const set<_Key, _Compare, _Alloc>& __x,
744                const set<_Key, _Compare, _Alloc>& __y)
745     { return !(__x < __y); }
746
747   /// See std::set::swap().
748   template<typename _Key, typename _Compare, typename _Alloc>
749     inline void
750     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
751     { __x.swap(__y); }
752
753 _GLIBCXX_END_NESTED_NAMESPACE
754
755 #endif /* _STL_SET_H */