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