197403Sobrien// Multiset implementation -*- C++ -*-
297403Sobrien
3169691Skan// Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
497403Sobrien//
597403Sobrien// This file is part of the GNU ISO C++ Library.  This library is free
697403Sobrien// software; you can redistribute it and/or modify it under the
797403Sobrien// terms of the GNU General Public License as published by the
897403Sobrien// Free Software Foundation; either version 2, or (at your option)
997403Sobrien// any later version.
1097403Sobrien
1197403Sobrien// This library is distributed in the hope that it will be useful,
1297403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of
1397403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1497403Sobrien// GNU General Public License for more details.
1597403Sobrien
1697403Sobrien// You should have received a copy of the GNU General Public License along
1797403Sobrien// with this library; see the file COPYING.  If not, write to the Free
18169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
1997403Sobrien// USA.
2097403Sobrien
2197403Sobrien// As a special exception, you may use this file as part of a free software
2297403Sobrien// library without restriction.  Specifically, if other files instantiate
2397403Sobrien// templates or use macros or inline functions from this file, or you compile
2497403Sobrien// this file and link it with other files to produce an executable, this
2597403Sobrien// file does not by itself cause the resulting executable to be covered by
2697403Sobrien// the GNU General Public License.  This exception does not however
2797403Sobrien// invalidate any other reasons why the executable file might be covered by
2897403Sobrien// the GNU General Public License.
2997403Sobrien
3097403Sobrien/*
3197403Sobrien *
3297403Sobrien * Copyright (c) 1994
3397403Sobrien * Hewlett-Packard Company
3497403Sobrien *
3597403Sobrien * Permission to use, copy, modify, distribute and sell this software
3697403Sobrien * and its documentation for any purpose is hereby granted without fee,
3797403Sobrien * provided that the above copyright notice appear in all copies and
3897403Sobrien * that both that copyright notice and this permission notice appear
3997403Sobrien * in supporting documentation.  Hewlett-Packard Company makes no
4097403Sobrien * representations about the suitability of this software for any
4197403Sobrien * purpose.  It is provided "as is" without express or implied warranty.
4297403Sobrien *
4397403Sobrien *
4497403Sobrien * Copyright (c) 1996
4597403Sobrien * Silicon Graphics Computer Systems, Inc.
4697403Sobrien *
4797403Sobrien * Permission to use, copy, modify, distribute and sell this software
4897403Sobrien * and its documentation for any purpose is hereby granted without fee,
4997403Sobrien * provided that the above copyright notice appear in all copies and
5097403Sobrien * that both that copyright notice and this permission notice appear
5197403Sobrien * in supporting documentation.  Silicon Graphics makes no
5297403Sobrien * representations about the suitability of this software for any
5397403Sobrien * purpose.  It is provided "as is" without express or implied warranty.
5497403Sobrien */
5597403Sobrien
5697403Sobrien/** @file stl_multiset.h
5797403Sobrien *  This is an internal header file, included by other library headers.
5897403Sobrien *  You should not attempt to use it directly.
5997403Sobrien */
6097403Sobrien
61132720Skan#ifndef _MULTISET_H
62132720Skan#define _MULTISET_H 1
6397403Sobrien
6497403Sobrien#include <bits/concept_check.h>
6597403Sobrien
66169691Skan_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
6797403Sobrien
68132720Skan  /**
69132720Skan   *  @brief A standard container made up of elements, which can be retrieved
70132720Skan   *  in logarithmic time.
71132720Skan   *
72132720Skan   *  @ingroup Containers
73132720Skan   *  @ingroup Assoc_containers
74132720Skan   *
75132720Skan   *  Meets the requirements of a <a href="tables.html#65">container</a>, a
76132720Skan   *  <a href="tables.html#66">reversible container</a>, and an
77132720Skan   *  <a href="tables.html#69">associative container</a> (using equivalent
78132720Skan   *  keys).  For a @c multiset<Key> the key_type and value_type are Key.
79132720Skan   *
80132720Skan   *  Multisets support bidirectional iterators.
81132720Skan   *
82132720Skan   *  @if maint
83132720Skan   *  The private tree data is declared exactly the same way for set and
84132720Skan   *  multiset; the distinction is made entirely in how the tree functions are
85132720Skan   *  called (*_unique versus *_equal, same as the standard).
86132720Skan   *  @endif
87132720Skan  */
88169691Skan  template <class _Key, class _Compare = std::less<_Key>,
89169691Skan	    class _Alloc = std::allocator<_Key> >
90132720Skan    class multiset
91132720Skan    {
92132720Skan      // concept requirements
93169691Skan      typedef typename _Alloc::value_type                   _Alloc_value_type;
94132720Skan      __glibcxx_class_requires(_Key, _SGIAssignableConcept)
95132720Skan      __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
96132720Skan				_BinaryFunctionConcept)
97169691Skan      __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
9897403Sobrien
99132720Skan    public:
100132720Skan      // typedefs:
101132720Skan      typedef _Key     key_type;
102132720Skan      typedef _Key     value_type;
103132720Skan      typedef _Compare key_compare;
104132720Skan      typedef _Compare value_compare;
105169691Skan      typedef _Alloc   allocator_type;
10697403Sobrien
107132720Skan    private:
108132720Skan      /// @if maint  This turns a red-black tree into a [multi]set.  @endif
109169691Skan      typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
110169691Skan
111169691Skan      typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
112169691Skan		       key_compare, _Key_alloc_type> _Rep_type;
113132720Skan      /// @if maint  The actual tree structure.  @endif
114132720Skan      _Rep_type _M_t;
11597403Sobrien
116132720Skan    public:
117169691Skan      typedef typename _Key_alloc_type::pointer             pointer;
118169691Skan      typedef typename _Key_alloc_type::const_pointer       const_pointer;
119169691Skan      typedef typename _Key_alloc_type::reference           reference;
120169691Skan      typedef typename _Key_alloc_type::const_reference     const_reference;
121132720Skan      // _GLIBCXX_RESOLVE_LIB_DEFECTS
122132720Skan      // DR 103. set::iterator is required to be modifiable,
123132720Skan      // but this allows modification of keys.
124169691Skan      typedef typename _Rep_type::const_iterator            iterator;
125169691Skan      typedef typename _Rep_type::const_iterator            const_iterator;
126169691Skan      typedef typename _Rep_type::const_reverse_iterator    reverse_iterator;
127169691Skan      typedef typename _Rep_type::const_reverse_iterator    const_reverse_iterator;
128169691Skan      typedef typename _Rep_type::size_type                 size_type;
129169691Skan      typedef typename _Rep_type::difference_type           difference_type;
13097403Sobrien
131169691Skan      // allocation/deallocation
13297403Sobrien
133169691Skan      /**
134169691Skan       *  @brief  Default constructor creates no elements.
135169691Skan       */
136132720Skan      multiset()
137236829Spfg      : _M_t() { }
13897403Sobrien
139132720Skan      explicit
140132720Skan      multiset(const _Compare& __comp,
141132720Skan	       const allocator_type& __a = allocator_type())
142132720Skan      : _M_t(__comp, __a) { }
14397403Sobrien
144132720Skan      /**
145132720Skan       *  @brief  Builds a %multiset from a range.
146132720Skan       *  @param  first  An input iterator.
147132720Skan       *  @param  last  An input iterator.
148132720Skan       *
149132720Skan       *  Create a %multiset consisting of copies of the elements from
150132720Skan       *  [first,last).  This is linear in N if the range is already sorted,
151132720Skan       *  and NlogN otherwise (where N is distance(first,last)).
152132720Skan       */
153132720Skan      template <class _InputIterator>
154132720Skan        multiset(_InputIterator __first, _InputIterator __last)
155236829Spfg	: _M_t()
156169691Skan        { _M_t._M_insert_equal(__first, __last); }
15797403Sobrien
158132720Skan      /**
159132720Skan       *  @brief  Builds a %multiset from a range.
160132720Skan       *  @param  first  An input iterator.
161132720Skan       *  @param  last  An input iterator.
162132720Skan       *  @param  comp  A comparison functor.
163132720Skan       *  @param  a  An allocator object.
164132720Skan       *
165132720Skan       *  Create a %multiset consisting of copies of the elements from
166132720Skan       *  [first,last).  This is linear in N if the range is already sorted,
167132720Skan       *  and NlogN otherwise (where N is distance(first,last)).
168132720Skan       */
169132720Skan      template <class _InputIterator>
170132720Skan        multiset(_InputIterator __first, _InputIterator __last,
171132720Skan		 const _Compare& __comp,
172132720Skan		 const allocator_type& __a = allocator_type())
173132720Skan	: _M_t(__comp, __a)
174169691Skan        { _M_t._M_insert_equal(__first, __last); }
17597403Sobrien
176132720Skan      /**
177132720Skan       *  @brief  %Multiset copy constructor.
178132720Skan       *  @param  x  A %multiset of identical element and allocator types.
179132720Skan       *
180132720Skan       *  The newly-created %multiset uses a copy of the allocation object used
181132720Skan       *  by @a x.
182132720Skan       */
183236829Spfg      multiset(const multiset& __x)
184132720Skan      : _M_t(__x._M_t) { }
18597403Sobrien
186132720Skan      /**
187132720Skan       *  @brief  %Multiset assignment operator.
188132720Skan       *  @param  x  A %multiset of identical element and allocator types.
189132720Skan       *
190132720Skan       *  All the elements of @a x are copied, but unlike the copy constructor,
191132720Skan       *  the allocator object is not copied.
192132720Skan       */
193236829Spfg      multiset&
194236829Spfg      operator=(const multiset& __x)
195132720Skan      {
196132720Skan	_M_t = __x._M_t;
197132720Skan	return *this;
198132720Skan      }
19997403Sobrien
200132720Skan      // accessors:
20197403Sobrien
202132720Skan      ///  Returns the comparison object.
203132720Skan      key_compare
204132720Skan      key_comp() const
205132720Skan      { return _M_t.key_comp(); }
206132720Skan      ///  Returns the comparison object.
207132720Skan      value_compare
208132720Skan      value_comp() const
209132720Skan      { return _M_t.key_comp(); }
210132720Skan      ///  Returns the memory allocation object.
211132720Skan      allocator_type
212132720Skan      get_allocator() const
213132720Skan      { return _M_t.get_allocator(); }
21497403Sobrien
215132720Skan      /**
216132720Skan       *  Returns a read/write iterator that points to the first element in the
217132720Skan       *  %multiset.  Iteration is done in ascending order according to the
218132720Skan       *  keys.
219132720Skan       */
220132720Skan      iterator
221132720Skan      begin() const
222132720Skan      { return _M_t.begin(); }
22397403Sobrien
224132720Skan      /**
225132720Skan       *  Returns a read/write iterator that points one past the last element in
226132720Skan       *  the %multiset.  Iteration is done in ascending order according to the
227132720Skan       *  keys.
228132720Skan       */
229132720Skan      iterator
230132720Skan      end() const
231132720Skan      { return _M_t.end(); }
23297403Sobrien
233132720Skan      /**
234132720Skan       *  Returns a read/write reverse iterator that points to the last element
235132720Skan       *  in the %multiset.  Iteration is done in descending order according to
236132720Skan       *  the keys.
237132720Skan       */
238132720Skan      reverse_iterator
239132720Skan      rbegin() const
240132720Skan      { return _M_t.rbegin(); }
24197403Sobrien
242132720Skan      /**
243132720Skan       *  Returns a read/write reverse iterator that points to the last element
244132720Skan       *  in the %multiset.  Iteration is done in descending order according to
245132720Skan       *  the keys.
246132720Skan       */
247132720Skan      reverse_iterator
248132720Skan      rend() const
249132720Skan      { return _M_t.rend(); }
25097403Sobrien
251132720Skan      ///  Returns true if the %set is empty.
252132720Skan      bool
253132720Skan      empty() const
254132720Skan      { return _M_t.empty(); }
25597403Sobrien
256132720Skan      ///  Returns the size of the %set.
257132720Skan      size_type
258132720Skan      size() const
259132720Skan      { return _M_t.size(); }
26097403Sobrien
261132720Skan      ///  Returns the maximum size of the %set.
262132720Skan      size_type
263132720Skan      max_size() const
264132720Skan      { return _M_t.max_size(); }
26597403Sobrien
266132720Skan      /**
267132720Skan       *  @brief  Swaps data with another %multiset.
268132720Skan       *  @param  x  A %multiset of the same element and allocator types.
269132720Skan       *
270132720Skan       *  This exchanges the elements between two multisets in constant time.
271132720Skan       *  (It is only swapping a pointer, an integer, and an instance of the @c
272132720Skan       *  Compare type (which itself is often stateless and empty), so it should
273132720Skan       *  be quite fast.)
274132720Skan       *  Note that the global std::swap() function is specialized such that
275132720Skan       *  std::swap(s1,s2) will feed to this function.
276132720Skan       */
277132720Skan      void
278236829Spfg      swap(multiset& __x)
279132720Skan      { _M_t.swap(__x._M_t); }
28097403Sobrien
281132720Skan      // insert/erase
282132720Skan      /**
283132720Skan       *  @brief Inserts an element into the %multiset.
284132720Skan       *  @param  x  Element to be inserted.
285132720Skan       *  @return An iterator that points to the inserted element.
286132720Skan       *
287132720Skan       *  This function inserts an element into the %multiset.  Contrary
288132720Skan       *  to a std::set the %multiset does not rely on unique keys and thus
289132720Skan       *  multiple copies of the same element can be inserted.
290132720Skan       *
291132720Skan       *  Insertion requires logarithmic time.
292132720Skan       */
293132720Skan      iterator
294132720Skan      insert(const value_type& __x)
295169691Skan      { return _M_t._M_insert_equal(__x); }
29697403Sobrien
297132720Skan      /**
298132720Skan       *  @brief Inserts an element into the %multiset.
299132720Skan       *  @param  position  An iterator that serves as a hint as to where the
300132720Skan       *                    element should be inserted.
301132720Skan       *  @param  x  Element to be inserted.
302132720Skan       *  @return An iterator that points to the inserted element.
303132720Skan       *
304132720Skan       *  This function inserts an element into the %multiset.  Contrary
305132720Skan       *  to a std::set the %multiset does not rely on unique keys and thus
306132720Skan       *  multiple copies of the same element can be inserted.
307132720Skan       *
308132720Skan       *  Note that the first parameter is only a hint and can potentially
309132720Skan       *  improve the performance of the insertion process.  A bad hint would
310132720Skan       *  cause no gains in efficiency.
311132720Skan       *
312132720Skan       *  See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
313132720Skan       *  for more on "hinting".
314132720Skan       *
315132720Skan       *  Insertion requires logarithmic time (if the hint is not taken).
316132720Skan       */
317132720Skan      iterator
318132720Skan      insert(iterator __position, const value_type& __x)
319169691Skan      { return _M_t._M_insert_equal(__position, __x); }
32097403Sobrien
321132720Skan      /**
322132720Skan       *  @brief A template function that attemps to insert a range of elements.
323132720Skan       *  @param  first  Iterator pointing to the start of the range to be
324132720Skan       *                 inserted.
325132720Skan       *  @param  last  Iterator pointing to the end of the range.
326132720Skan       *
327132720Skan       *  Complexity similar to that of the range constructor.
328132720Skan       */
329132720Skan      template <class _InputIterator>
330132720Skan        void
331132720Skan        insert(_InputIterator __first, _InputIterator __last)
332169691Skan        { _M_t._M_insert_equal(__first, __last); }
33397403Sobrien
334132720Skan      /**
335132720Skan       *  @brief Erases an element from a %multiset.
336132720Skan       *  @param  position  An iterator pointing to the element to be erased.
337132720Skan       *
338132720Skan       *  This function erases an element, pointed to by the given iterator,
339132720Skan       *  from a %multiset.  Note that this function only erases the element,
340132720Skan       *  and that if the element is itself a pointer, the pointed-to memory is
341132720Skan       *  not touched in any way.  Managing the pointer is the user's
342132720Skan       *  responsibilty.
343132720Skan       */
344132720Skan      void
345132720Skan      erase(iterator __position)
346169691Skan      { _M_t.erase(__position); }
34797403Sobrien
348132720Skan      /**
349132720Skan       *  @brief Erases elements according to the provided key.
350132720Skan       *  @param  x  Key of element to be erased.
351132720Skan       *  @return  The number of elements erased.
352132720Skan       *
353132720Skan       *  This function erases all elements located by the given key from a
354132720Skan       *  %multiset.
355132720Skan       *  Note that this function only erases the element, and that if
356132720Skan       *  the element is itself a pointer, the pointed-to memory is not touched
357132720Skan       *  in any way.  Managing the pointer is the user's responsibilty.
358132720Skan       */
359132720Skan      size_type
360132720Skan      erase(const key_type& __x)
361132720Skan      { return _M_t.erase(__x); }
36297403Sobrien
363132720Skan      /**
364132720Skan       *  @brief Erases a [first,last) range of elements from a %multiset.
365132720Skan       *  @param  first  Iterator pointing to the start of the range to be
366132720Skan       *                 erased.
367132720Skan       *  @param  last  Iterator pointing to the end of the range to be erased.
368132720Skan       *
369132720Skan       *  This function erases a sequence of elements from a %multiset.
370132720Skan       *  Note that this function only erases the elements, and that if
371132720Skan       *  the elements themselves are pointers, the pointed-to memory is not
372132720Skan       *  touched in any way.  Managing the pointer is the user's responsibilty.
373132720Skan       */
374132720Skan      void
375132720Skan      erase(iterator __first, iterator __last)
376169691Skan      { _M_t.erase(__first, __last); }
37797403Sobrien
378132720Skan      /**
379132720Skan       *  Erases all elements in a %multiset.  Note that this function only
380132720Skan       *  erases the elements, and that if the elements themselves are pointers,
381132720Skan       *  the pointed-to memory is not touched in any way.  Managing the pointer
382132720Skan       *  is the user's responsibilty.
383132720Skan       */
384132720Skan      void
385132720Skan      clear()
386132720Skan      { _M_t.clear(); }
387132720Skan
388132720Skan      // multiset operations:
389132720Skan
390132720Skan      /**
391132720Skan       *  @brief Finds the number of elements with given key.
392132720Skan       *  @param  x  Key of elements to be located.
393132720Skan       *  @return Number of elements with specified key.
394132720Skan       */
395132720Skan      size_type
396132720Skan      count(const key_type& __x) const
397132720Skan      { return _M_t.count(__x); }
398132720Skan
399132720Skan      // _GLIBCXX_RESOLVE_LIB_DEFECTS
400132720Skan      // 214.  set::find() missing const overload
401132720Skan      //@{
402132720Skan      /**
403132720Skan       *  @brief Tries to locate an element in a %set.
404132720Skan       *  @param  x  Element to be located.
405132720Skan       *  @return  Iterator pointing to sought-after element, or end() if not
406132720Skan       *           found.
407132720Skan       *
408132720Skan       *  This function takes a key and tries to locate the element with which
409132720Skan       *  the key matches.  If successful the function returns an iterator
410132720Skan       *  pointing to the sought after element.  If unsuccessful it returns the
411132720Skan       *  past-the-end ( @c end() ) iterator.
412132720Skan       */
413132720Skan      iterator
414132720Skan      find(const key_type& __x)
415132720Skan      { return _M_t.find(__x); }
416132720Skan
417132720Skan      const_iterator
418132720Skan      find(const key_type& __x) const
419132720Skan      { return _M_t.find(__x); }
420132720Skan      //@}
421132720Skan
422132720Skan      //@{
423132720Skan      /**
424132720Skan       *  @brief Finds the beginning of a subsequence matching given key.
425132720Skan       *  @param  x  Key to be located.
426132720Skan       *  @return  Iterator pointing to first element equal to or greater
427132720Skan       *           than key, or end().
428132720Skan       *
429132720Skan       *  This function returns the first element of a subsequence of elements
430132720Skan       *  that matches the given key.  If unsuccessful it returns an iterator
431132720Skan       *  pointing to the first element that has a greater value than given key
432132720Skan       *  or end() if no such element exists.
433132720Skan       */
434132720Skan      iterator
435132720Skan      lower_bound(const key_type& __x)
436132720Skan      { return _M_t.lower_bound(__x); }
437132720Skan
438132720Skan      const_iterator
439132720Skan      lower_bound(const key_type& __x) const
440132720Skan      { return _M_t.lower_bound(__x); }
441132720Skan      //@}
442132720Skan
443132720Skan      //@{
444132720Skan      /**
445132720Skan       *  @brief Finds the end of a subsequence matching given key.
446132720Skan       *  @param  x  Key to be located.
447132720Skan       *  @return Iterator pointing to the first element
448132720Skan       *          greater than key, or end().
449132720Skan       */
450132720Skan      iterator
451132720Skan      upper_bound(const key_type& __x)
452132720Skan      { return _M_t.upper_bound(__x); }
453132720Skan
454132720Skan      const_iterator
455132720Skan      upper_bound(const key_type& __x) const
456132720Skan      { return _M_t.upper_bound(__x); }
457132720Skan      //@}
458132720Skan
459132720Skan      //@{
460132720Skan      /**
461132720Skan       *  @brief Finds a subsequence matching given key.
462132720Skan       *  @param  x  Key to be located.
463132720Skan       *  @return  Pair of iterators that possibly points to the subsequence
464132720Skan       *           matching given key.
465132720Skan       *
466132720Skan       *  This function is equivalent to
467132720Skan       *  @code
468132720Skan       *    std::make_pair(c.lower_bound(val),
469132720Skan       *                   c.upper_bound(val))
470132720Skan       *  @endcode
471132720Skan       *  (but is faster than making the calls separately).
472132720Skan       *
473132720Skan       *  This function probably only makes sense for multisets.
474132720Skan       */
475169691Skan      std::pair<iterator, iterator>
476132720Skan      equal_range(const key_type& __x)
477132720Skan      { return _M_t.equal_range(__x); }
478132720Skan
479169691Skan      std::pair<const_iterator, const_iterator>
480132720Skan      equal_range(const key_type& __x) const
481132720Skan      { return _M_t.equal_range(__x); }
482132720Skan
483132720Skan      template <class _K1, class _C1, class _A1>
484132720Skan        friend bool
485169691Skan        operator== (const multiset<_K1, _C1, _A1>&,
486169691Skan		    const multiset<_K1, _C1, _A1>&);
487132720Skan
488132720Skan      template <class _K1, class _C1, class _A1>
489132720Skan        friend bool
490169691Skan        operator< (const multiset<_K1, _C1, _A1>&,
491169691Skan		   const multiset<_K1, _C1, _A1>&);
492132720Skan    };
493132720Skan
494132720Skan  /**
495132720Skan   *  @brief  Multiset equality comparison.
496132720Skan   *  @param  x  A %multiset.
497132720Skan   *  @param  y  A %multiset of the same type as @a x.
498132720Skan   *  @return  True iff the size and elements of the multisets are equal.
499132720Skan   *
500132720Skan   *  This is an equivalence relation.  It is linear in the size of the
501132720Skan   *  multisets.
502132720Skan   *  Multisets are considered equivalent if their sizes are equal, and if
503132720Skan   *  corresponding elements compare equal.
504132720Skan  */
505132720Skan  template <class _Key, class _Compare, class _Alloc>
506132720Skan    inline bool
507169691Skan    operator==(const multiset<_Key, _Compare, _Alloc>& __x,
508169691Skan	       const multiset<_Key, _Compare, _Alloc>& __y)
509132720Skan    { return __x._M_t == __y._M_t; }
510132720Skan
511132720Skan  /**
512132720Skan   *  @brief  Multiset ordering relation.
513132720Skan   *  @param  x  A %multiset.
514132720Skan   *  @param  y  A %multiset of the same type as @a x.
515132720Skan   *  @return  True iff @a x is lexicographically less than @a y.
516132720Skan   *
517132720Skan   *  This is a total ordering relation.  It is linear in the size of the
518132720Skan   *  maps.  The elements must be comparable with @c <.
519132720Skan   *
520132720Skan   *  See std::lexicographical_compare() for how the determination is made.
521132720Skan  */
522132720Skan  template <class _Key, class _Compare, class _Alloc>
523132720Skan    inline bool
524169691Skan    operator<(const multiset<_Key, _Compare, _Alloc>& __x,
525169691Skan	      const multiset<_Key, _Compare, _Alloc>& __y)
526132720Skan    { return __x._M_t < __y._M_t; }
527132720Skan
528132720Skan  ///  Returns !(x == y).
529132720Skan  template <class _Key, class _Compare, class _Alloc>
530132720Skan    inline bool
531169691Skan    operator!=(const multiset<_Key, _Compare, _Alloc>& __x,
532169691Skan	       const multiset<_Key, _Compare, _Alloc>& __y)
533132720Skan    { return !(__x == __y); }
534132720Skan
535132720Skan  ///  Returns y < x.
536132720Skan  template <class _Key, class _Compare, class _Alloc>
537132720Skan    inline bool
538132720Skan    operator>(const multiset<_Key,_Compare,_Alloc>& __x,
539132720Skan	      const multiset<_Key,_Compare,_Alloc>& __y)
540132720Skan    { return __y < __x; }
541132720Skan
542132720Skan  ///  Returns !(y < x)
543132720Skan  template <class _Key, class _Compare, class _Alloc>
544132720Skan    inline bool
545169691Skan    operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
546169691Skan	       const multiset<_Key, _Compare, _Alloc>& __y)
547132720Skan    { return !(__y < __x); }
548132720Skan
549132720Skan  ///  Returns !(x < y)
550132720Skan  template <class _Key, class _Compare, class _Alloc>
551132720Skan    inline bool
552169691Skan    operator>=(const multiset<_Key, _Compare, _Alloc>& __x,
553169691Skan	       const multiset<_Key, _Compare, _Alloc>& __y)
554132720Skan    { return !(__x < __y); }
555132720Skan
556132720Skan  /// See std::multiset::swap().
557132720Skan  template <class _Key, class _Compare, class _Alloc>
558132720Skan    inline void
559169691Skan    swap(multiset<_Key, _Compare, _Alloc>& __x,
560169691Skan	 multiset<_Key, _Compare, _Alloc>& __y)
561132720Skan    { __x.swap(__y); }
562132720Skan
563169691Skan_GLIBCXX_END_NESTED_NAMESPACE
56497403Sobrien
565132720Skan#endif /* _MULTISET_H */
566