home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / set.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  21.2 KB  |  635 lines

  1. #ifndef __SET_H
  2. #define __SET_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #ifndef __STD_SET__
  6. #define __STD_SET__
  7.  
  8. /***************************************************************************
  9.  *
  10.  * set - declarations for the Standard Library set class
  11.  *
  12.  ***************************************************************************
  13.  *
  14.  * Copyright (c) 1994
  15.  * Hewlett-Packard Company
  16.  *
  17.  * Permission to use, copy, modify, distribute and sell this software
  18.  * and its documentation for any purpose is hereby granted without fee,
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both that copyright notice and this permission notice appear
  21.  * in supporting documentation.  Hewlett-Packard Company makes no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied warranty.
  24.  *
  25.  *
  26.  ***************************************************************************
  27.  *
  28.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  29.  *
  30.  * This computer software is owned by Rogue Wave Software, Inc. and is
  31.  * protected by U.S. copyright laws and other laws and by international
  32.  * treaties.  This computer software is furnished by Rogue Wave Software,
  33.  * Inc. pursuant to a written license agreement and may be used, copied,
  34.  * transmitted, and stored only in accordance with the terms of such
  35.  * license and with the inclusion of the above copyright notice.  This
  36.  * computer software or any other copies thereof may not be provided or
  37.  * otherwise made available to any other person.
  38.  *
  39.  * U.S. Government Restricted Rights.  This computer software is provided
  40.  * with Restricted Rights.  Use, duplication, or disclosure by the
  41.  * Government is subject to restrictions as set forth in subparagraph (c)
  42.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  43.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  44.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  45.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  46.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  47.  *
  48.  **************************************************************************/
  49.  
  50. #include <stdcomp.h>
  51.  
  52. #ifdef __BORLANDC__
  53. #pragma option -w-inl
  54. #endif
  55.  
  56. #include <memory>
  57. #include <functional>
  58. #include <rw/tree> 
  59.  
  60. #ifndef _RWSTD_NO_NAMESPACE
  61. namespace __rwstd {
  62. #endif
  63.  
  64. //
  65. // This is used in the implementation of set and multiset.
  66. //
  67.  
  68.   template <class T, class U>
  69.   struct __ident : public _RW_STD::unary_function<T, U>
  70.   {
  71.     const U& operator() (const T& x) const { return x; }
  72.   };
  73.  
  74. #ifndef _RWSTD_NO_NAMESPACE
  75. } namespace std {
  76. #endif
  77.  
  78. //
  79. // Note that _RWSTD_COMPLEX_DEFAULT(x)
  80. // will expand to: ' = x', or nothing,
  81. // depending on your compiler's capabilities and/or
  82. // flag settings (see stdcomp.h).
  83. //
  84.   template <class Key, 
  85.   class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  86.   class Allocator _RWSTD_COMPLEX_DEFAULT(allocator<Key>) >  
  87.   class set
  88.   {
  89.   public:
  90.     //
  91.     // Types
  92.     //
  93.     typedef Key                key_type;
  94.     typedef Key                value_type;
  95.     typedef Compare            key_compare;
  96.     typedef Compare            value_compare;
  97.     typedef Allocator          allocator_type;
  98.  
  99.   private:
  100.     
  101.     typedef __RWSTD::__rb_tree<key_type, value_type, 
  102.     __RWSTD::__ident<value_type, key_type>, 
  103.     key_compare, allocator_type> __rep_type;
  104.     __rep_type __t;
  105.  
  106.   public:
  107.     //
  108.     // Types
  109.     //
  110.     typedef _TYPENAME __rep_type::reference               reference;
  111.     typedef _TYPENAME __rep_type::const_reference         const_reference;
  112.     typedef _TYPENAME __rep_type::iterator                iterator;
  113.     typedef _TYPENAME __rep_type::const_iterator          const_iterator;
  114.     typedef _TYPENAME __rep_type::size_type               size_type;
  115.     typedef _TYPENAME __rep_type::difference_type         difference_type;
  116.     typedef _TYPENAME __rep_type::pointer                 pointer;
  117.     typedef _TYPENAME __rep_type::const_pointer           const_pointer;
  118.     typedef _TYPENAME __rep_type::reverse_iterator        reverse_iterator;
  119.     typedef _TYPENAME __rep_type::const_reverse_iterator  const_reverse_iterator;
  120.  
  121.     //
  122.     // construct/copy/destroy
  123.     //
  124.     _EXPLICIT set (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  125.                    const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, false, alloc) {}
  126.  
  127. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  128.     set () : __t(Compare(), false, Allocator()) {}
  129.  
  130.     _EXPLICIT set (const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, false, Allocator()) {}
  131. #endif
  132.  
  133. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  134.     template<class InputIterator>
  135.     set (InputIterator first, InputIterator last,
  136.          const Compare& comp = Compare(),
  137.          const Allocator& alloc = Allocator()) : __t(comp, false, alloc)
  138.     {
  139.       while (first != last) __t.insert(*first++);
  140.     }
  141. #else
  142.     set (const value_type* first, const value_type* last,
  143.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  144.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, false, alloc)
  145.     {
  146.       while (first != last) __t.insert(*first++);
  147.     }
  148.     
  149.     set (const_iterator first, const_iterator last,
  150.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  151.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, false, alloc)
  152.     {
  153.       while (first != last) __t.insert(*first++);
  154.     }
  155.  
  156. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  157.     set (const value_type* first, const value_type* last) : __t(Compare(), false, Allocator())
  158.     {
  159.       while (first != last) __t.insert(*first++);
  160.     }
  161.     
  162.     set (const value_type* first, const value_type* last,
  163.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, false, Allocator())
  164.     {
  165.       while (first != last) __t.insert(*first++);
  166.     }
  167.     
  168.     set (const_iterator first, const_iterator last) : __t(Compare(), false, Allocator())
  169.     {
  170.       while (first != last) __t.insert(*first++);
  171.     }
  172.  
  173.     set (const_iterator first, const_iterator last,
  174.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, false, Allocator())
  175.     {
  176.       while (first != last) __t.insert(*first++);
  177.     }
  178. #endif
  179. #endif
  180.  
  181.     set (const set<Key, Compare, Allocator>& x) : __t(x.__t, false) {}
  182.     set<Key, Compare, Allocator>& operator= (const set<Key, Compare, Allocator>& x)
  183.     {
  184.       __t = x.__t; return *this;
  185.     }
  186.     allocator_type get_allocator() const
  187.     {
  188.       return __t.get_allocator();
  189.     }
  190.  
  191.     //
  192.     // iterators
  193.     //
  194.     iterator                 begin  ()       { return __t.begin();  }
  195.     const_iterator           begin  () const { return __t.begin();  }
  196.     iterator                 end    ()       { return __t.end();    }
  197.     const_iterator           end    () const { return __t.end();    }
  198.     reverse_iterator         rbegin ()       { return __t.rbegin(); } 
  199.     const_reverse_iterator   rbegin () const { return __t.rbegin(); } 
  200.     reverse_iterator         rend   ()       { return __t.rend();   }
  201.     const_reverse_iterator   rend   () const { return __t.rend();   }
  202.  
  203.     //
  204.     // capacity
  205.     //
  206.     bool        empty    () const { return __t.empty();    }
  207.     size_type   size     () const { return __t.size();     }
  208.     size_type   max_size () const { return __t.max_size(); }
  209.  
  210.     //
  211.     // modifiers
  212.     //
  213. #ifdef _RWSTD_NO_MEMBER_TYPE_TPARAM
  214.     typedef _TYPENAME __rep_type::iterator t_iterator;
  215. #endif
  216. #ifndef _RWSTD_NO_RET_TEMPLATE
  217.     pair<iterator,bool> insert (const value_type& x)
  218. #else
  219.       typedef pair<iterator, bool> pair_iterator_bool;
  220.       //
  221.       // typedef done to get around compiler bug.
  222.       //
  223.       pair_iterator_bool insert (const value_type& x)
  224. #endif
  225.     {
  226. #ifndef _RWSTD_NO_MEMBER_TYPE_TPARAM
  227.       pair<_TYPENAME __rep_type::iterator, bool> p = __t.insert(x); 
  228. #else
  229.       pair<t_iterator,bool> p = __t.insert(x); 
  230. #endif
  231.       return pair<iterator, bool>(p.first, p.second);
  232.     }
  233.     iterator insert (iterator position, const value_type& x)
  234.     {
  235.       return __t.insert(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,position), x);
  236.     }
  237.  
  238. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  239.     template<class InputIterator>
  240.     void insert (InputIterator first, InputIterator last)
  241.     {
  242.       while (first != last) __t.insert(*first++);
  243.     }
  244. #else
  245.     void insert (const value_type* first, const value_type* last)
  246.     {
  247.       while (first != last) __t.insert(*first++);
  248.     }
  249.     void insert (const_iterator first, const_iterator last)
  250.     {
  251.       while (first != last) __t.insert(*first++);
  252.     }
  253. #endif
  254.  
  255.     void erase (iterator position)
  256.     {
  257.       __t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,position));
  258.     }
  259.     size_type erase (const key_type& x)
  260.     {
  261.       return __t.erase(x); 
  262.     }
  263.     void erase (iterator first, iterator last)
  264.     {
  265.       __t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,first),
  266.                        _RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,last));
  267.     }
  268.     void swap (set<Key, Compare, Allocator>& x) { __t.swap(x.__t); }
  269.     void clear ()   { erase(begin(),end()); }
  270.  
  271.     //
  272.     // observers
  273.     //
  274.     key_compare        key_comp   () const { return __t.key_comp(); }
  275.     value_compare      value_comp () const { return __t.key_comp(); }
  276.  
  277.     //
  278.     // set operations
  279.     //
  280.     iterator  find        (const key_type& x) const { return __t.find(x);       }
  281.     size_type count       (const key_type& x) const { return __t.count(x);      }
  282.     iterator  lower_bound (const key_type& x) const { return __t.lower_bound(x);}
  283.     iterator  upper_bound (const key_type& x) const { return __t.upper_bound(x);}
  284.  
  285. #ifndef _RWSTD_NO_RET_TEMPLATE
  286.     pair<iterator,iterator> equal_range(const key_type& x) const
  287. #else
  288.       typedef  pair<iterator, iterator> pair_iterator_iterator;
  289.     //
  290.     // typedef done to get around compiler bug
  291.     //
  292.     pair_iterator_iterator equal_range (const key_type& x) const
  293. #endif
  294.     {
  295.       return __t.equal_range(x);
  296.     }
  297.  
  298. #ifndef _RWSTD_STRICT_ANSI
  299.     // Non-standard function for setting buffer allocation size
  300.     size_type allocation_size() { return __t.allocation_size(); }
  301.     size_type allocation_size(size_type new_size) 
  302.     { 
  303.       return __t.allocation_size(new_size);
  304.     }
  305. #endif  
  306.   };
  307.  
  308. //
  309. // Note that _RWSTD_COMPLEX_DEFAULT(x)
  310. // will expand to: ' = x', or nothing,
  311. // depending on your compiler's capabilities and/or
  312. // flag settings (see stdcomp.h).
  313. //
  314.   template <class Key, 
  315.   class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  316.   class Allocator _RWSTD_COMPLEX_DEFAULT(allocator<Key>) > 
  317.   class multiset
  318.   {
  319.   public:
  320.     //  
  321.     // types
  322.     //
  323.     typedef Key       key_type;
  324.     typedef Key       value_type;
  325.     typedef Compare   key_compare;
  326.     typedef Compare   value_compare;
  327.     typedef Allocator allocator_type;
  328.   private:
  329.     
  330.     typedef __RWSTD::__rb_tree<key_type, value_type, 
  331.       __RWSTD::__ident<value_type, key_type>, 
  332.       key_compare, allocator_type> __rep_type;
  333.     __rep_type __t;
  334.  
  335.   public:
  336.     //
  337.     // types
  338.     //
  339.     typedef _TYPENAME __rep_type::reference               reference;
  340.     typedef _TYPENAME __rep_type::const_reference         const_reference;
  341.     typedef _TYPENAME __rep_type::iterator                iterator;
  342.     typedef _TYPENAME __rep_type::const_iterator          const_iterator;
  343.     typedef _TYPENAME __rep_type::size_type               size_type;
  344.     typedef _TYPENAME __rep_type::difference_type         difference_type;
  345.     typedef _TYPENAME __rep_type::pointer                 pointer;
  346.     typedef _TYPENAME __rep_type::const_pointer           const_pointer;
  347.     typedef _TYPENAME __rep_type::reverse_iterator        reverse_iterator;
  348.     typedef _TYPENAME __rep_type::const_reverse_iterator  const_reverse_iterator;
  349.  
  350.     //
  351.     // construct/copy/destroy
  352.     //
  353.     _EXPLICIT multiset (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  354.                         const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, true, alloc) {}
  355.  
  356. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  357.     _EXPLICIT multiset (void) : __t(Compare(), true, Allocator()) {}
  358.  
  359.     _EXPLICIT multiset (const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, true, Allocator()) {}
  360. #endif
  361.  
  362. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  363.     template<class InputIterator>
  364.     multiset (InputIterator first, InputIterator last, 
  365.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  366.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, true, alloc)
  367.     {
  368.       while (first != last) __t.insert(*first++);
  369.     }
  370. #else
  371.     multiset (const value_type* first, const value_type* last, 
  372.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  373.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, true, alloc)
  374.     {
  375.       while (first != last) __t.insert(*first++);
  376.     }
  377.     multiset (const_iterator first, const_iterator last, 
  378.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  379.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : __t(comp, true, alloc)
  380.     {
  381.       while (first != last) __t.insert(*first++);
  382.     }
  383.  
  384. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  385.     multiset (const value_type* first, const value_type* last) : __t(Compare(), true, Allocator())
  386.     {
  387.       while (first != last) __t.insert(*first++);
  388.     }
  389.  
  390.     multiset (const value_type* first, const value_type* last, 
  391.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, true, Allocator())
  392.     {
  393.       while (first != last) __t.insert(*first++);
  394.     }
  395.  
  396.     multiset (const_iterator first, const_iterator last) : __t(Compare(), true, Allocator())
  397.     {
  398.       while (first != last) __t.insert(*first++);
  399.     }
  400.  
  401.     multiset (const_iterator first, const_iterator last, 
  402.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare())) : __t(comp, true, Allocator())
  403.     {
  404.       while (first != last) __t.insert(*first++);
  405.     }
  406. #endif
  407.  
  408. #endif
  409.  
  410.     multiset (const multiset<Key, Compare, Allocator>& x) : __t(x.__t, true) {}
  411.     multiset<Key, Compare, Allocator>& 
  412.     operator= (const multiset<Key, Compare, Allocator>& x)
  413.     {
  414.       __t = x.__t; return *this;
  415.     }
  416.     allocator_type get_allocator() const
  417.     {
  418.       return __t.get_allocator();
  419.     }
  420.  
  421.     //
  422.     // iterators
  423.     //
  424.     iterator                 begin  ()       { return __t.begin();  }
  425.     const_iterator           begin  () const { return __t.begin();  }
  426.     iterator                 end    ()       { return __t.end();    }
  427.     const_iterator           end    () const { return __t.end();    }
  428.     reverse_iterator         rbegin ()       { return __t.rbegin(); } 
  429.     const_reverse_iterator   rbegin () const { return __t.rbegin(); } 
  430.     reverse_iterator         rend   ()       { return __t.rend();   }
  431.     const_reverse_iterator   rend   () const { return __t.rend();   }
  432.  
  433.     //
  434.     // capacity
  435.     //
  436.     bool       empty    () const { return __t.empty();    }
  437.     size_type  size     () const { return __t.size();     }
  438.     size_type  max_size () const { return __t.max_size(); }
  439.  
  440.     //
  441.     // modifiers
  442.     //
  443.     iterator insert (const value_type& x) { return __t.insert(x).first; }
  444.     iterator insert (iterator position, const value_type& x)
  445.     {
  446.       return __t.insert(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,position), x);
  447.     }
  448.  
  449. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  450.     template<class InputIterator>
  451.     void insert (InputIterator first, InputIterator last)
  452.     {
  453.       while (first != last) __t.insert(*first++);
  454.     }
  455. #else
  456.     void insert (const value_type* first, const value_type* last)
  457.     {
  458.       while (first != last) __t.insert(*first++);
  459.     }
  460.     void insert (const_iterator first, const_iterator last)
  461.     {
  462.       while (first != last) __t.insert(*first++);
  463.     }
  464. #endif
  465.  
  466.     void erase (iterator position)
  467.     {
  468.       __t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,position));
  469.     }
  470.     size_type erase (const key_type& x) { return __t.erase(x); }
  471.     void erase (iterator first, iterator last)
  472.     {
  473.       __t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,first),
  474.                        _RWSTD_REINTERPRET_CAST(_TYPENAME __rep_type::iterator&,last)); 
  475.     }
  476.     void swap (multiset<Key, Compare, Allocator>& x) { __t.swap(x.__t); }
  477.     void clear ()   { erase(begin(),end()); }
  478.  
  479.     //
  480.     // observers
  481.     //
  482.     key_compare   key_comp   () const { return __t.key_comp(); }
  483.     value_compare value_comp () const { return __t.key_comp(); }
  484.  
  485.     //
  486.     // set operations
  487.     //
  488.     iterator  find        (const key_type& x) const { return __t.find(x);  }
  489.     size_type count       (const key_type& x) const { return __t.count(x); }
  490.     iterator  lower_bound (const key_type& x) const
  491.     {
  492.       return __t.lower_bound(x);
  493.     }
  494.     iterator  upper_bound (const key_type& x) const
  495.     {
  496.       return __t.upper_bound(x); 
  497.     }
  498. #ifndef _RWSTD_NO_RET_TEMPLATE
  499.     pair<iterator,iterator> equal_range (const key_type& x) const
  500. #else
  501.       typedef  pair<iterator, iterator> pair_iterator_iterator; 
  502.     //
  503.     // typedef done to get around compiler bug
  504.     //
  505.     pair_iterator_iterator equal_range (const key_type& x) const
  506. #endif
  507.     {
  508.       return __t.equal_range(x);
  509.     }
  510.  
  511. #ifndef _RWSTD_STRICT_ANSI
  512.     // Non-standard function for setting buffer allocation size
  513.     size_type allocation_size() { return __t.allocation_size(); }
  514.     size_type allocation_size(size_type new_size) 
  515.     { 
  516.       return __t.allocation_size(new_size);
  517.     }
  518. #endif  
  519.   };
  520.  
  521.   template <class Key, class Compare, class Allocator>
  522.   inline bool operator== (const set<Key, Compare, Allocator>& x, 
  523.                           const set<Key, Compare, Allocator>& y)
  524.   {
  525.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  526.   }
  527.  
  528.   template <class Key, class Compare, class Allocator>
  529.   inline bool operator< (const set<Key, Compare, Allocator>& x, 
  530.                          const set<Key, Compare, Allocator>& y)
  531.   {
  532.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  533.   }
  534.  
  535. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  536.   template <class Key, class Compare, class Allocator>
  537.   inline bool operator!= (const set<Key,Compare,Allocator>& x, 
  538.                           const set<Key,Compare,Allocator>& y)
  539.   {
  540.     return !(x == y);
  541.   }
  542.  
  543.   template <class Key, class Compare, class Allocator>
  544.   inline bool operator> (const set<Key,Compare,Allocator>& x, 
  545.                          const set<Key,Compare,Allocator>& y)
  546.   {
  547.     return y < x;
  548.   }
  549.  
  550.   template <class Key, class Compare, class Allocator>
  551.   inline bool operator>= (const set<Key,Compare,Allocator>& x, 
  552.                           const set<Key,Compare,Allocator>& y)
  553.   {
  554.     return !(x < y);
  555.   }
  556.  
  557.   template <class Key, class Compare, class Allocator>
  558.   inline bool operator<= (const set<Key,Compare,Allocator>& x, 
  559.                           const set<Key,Compare,Allocator>& y)
  560.   {
  561.     return !(y <  x);
  562.   }
  563.  
  564.   template <class Key, class Compare, class Allocator>
  565.   void swap(set<Key,Compare,Allocator>& a, 
  566.             set<Key,Compare,Allocator>& b)
  567.   {
  568.     a.swap(b);
  569.   }
  570. #endif
  571.  
  572.   template <class Key, class Compare, class Allocator>
  573.   inline bool operator== (const multiset<Key, Compare, Allocator>& x, 
  574.                           const multiset<Key, Compare, Allocator>& y)
  575.   {
  576.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  577.   }
  578.  
  579.   template <class Key, class Compare, class Allocator>
  580.   inline bool operator< (const multiset<Key, Compare, Allocator>& x, 
  581.                          const multiset<Key, Compare, Allocator>& y)
  582.   {
  583.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  584.   }
  585.  
  586. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  587.   template <class Key, class Compare, class Allocator>
  588.   inline bool operator!= (const multiset<Key,Compare,Allocator>& x, 
  589.                           const multiset<Key,Compare,Allocator>& y)
  590.   {
  591.     return !(x == y);
  592.   }
  593.  
  594.   template <class Key, class Compare, class Allocator>
  595.   inline bool operator> (const multiset<Key,Compare,Allocator>& x, 
  596.                          const multiset<Key,Compare,Allocator>& y)
  597.   {
  598.     return y < x;
  599.   }
  600.  
  601.   template <class Key, class Compare, class Allocator>
  602.   inline bool operator>= (const multiset<Key,Compare,Allocator>& x, 
  603.                           const multiset<Key,Compare,Allocator>& y)
  604.   {
  605.     return !(x < y);
  606.   }
  607.  
  608.   template <class Key, class Compare, class Allocator>
  609.   inline bool operator<= (const multiset<Key,Compare,Allocator>& x, 
  610.                           const multiset<Key,Compare,Allocator>& y)
  611.   {
  612.     return !(y <  x);
  613.   }
  614.  
  615.   template <class Key, class Compare, class Allocator>
  616.   void swap(multiset<Key,Compare,Allocator>& a, 
  617.             multiset<Key,Compare,Allocator>& b)
  618.   {
  619.     a.swap(b);
  620.   }
  621. #endif
  622.  
  623. #ifndef _RWSTD_NO_NAMESPACE
  624. }
  625. #endif
  626.  
  627. #endif
  628.  
  629. #ifndef __USING_STD_NAMES__
  630.   using namespace std;
  631. #endif
  632.  
  633. #pragma option pop
  634. #endif /* __SET_H */
  635.