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

  1. #ifndef __MAP_H
  2. #define __MAP_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #ifndef __STD_MAP__
  6. #define __STD_MAP__
  7.  
  8. /***************************************************************************
  9.  *
  10.  * map - declarations for the Standard Library map 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 map and multimap.
  66. //
  67.  
  68.   template <class T, class U>
  69.   struct __select1st : public _RW_STD::unary_function<T, U>
  70.   {
  71.     const U& operator() (const T& x) const { return x.first; }
  72.   };
  73.  
  74. #ifndef _RWSTD_NO_NAMESPACE
  75. }
  76.  
  77. namespace std {
  78. #endif
  79.  
  80. //
  81. // First the map stuff.
  82. //
  83.   
  84. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES  
  85.   template <class Key, class T, class Compare = less<Key>, 
  86. #ifndef _RWSTD_NO_CONST_INST
  87.   class Allocator = allocator<pair<const Key,T> > >
  88. #else
  89.   class Allocator = allocator<pair<Key,T> > >
  90. #endif // _RWSTD_NO_CONST_INST
  91. #else
  92.   template <class Key, class T, class Compare, class Allocator>
  93. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  94.   class map
  95.   {
  96.   public:
  97.     //
  98.     // types
  99.     //
  100.     typedef Key                key_type;
  101.     typedef T                  mapped_type;
  102. #ifndef _RWSTD_NO_CONST_INST
  103.     typedef pair<const Key, T> value_type;
  104. #else
  105.     typedef pair<Key, T>       value_type;
  106. #endif
  107.     typedef Compare            key_compare;
  108.     typedef Allocator          allocator_type;
  109.     
  110.   private:
  111.     
  112.     typedef __RWSTD::__rb_tree<key_type, value_type,
  113.       __RWSTD::__select1st<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.     class value_compare : public binary_function<value_type, value_type, bool>
  133.     {
  134.       friend class map<Key, T, Compare, Allocator>;
  135.     protected:
  136.       Compare comp;
  137.       value_compare (Compare c) : comp(c) {}
  138.     public:
  139.       bool operator() (const value_type& x, const value_type& y) const
  140.       {
  141.         return comp(x.first, y.first);
  142.       }
  143.     };
  144.     //
  145.     // construct/copy/destroy
  146.     //
  147.     _EXPLICIT map (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  148.                    const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) 
  149.       : __t(comp, false, alloc) {}
  150.  
  151. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  152.     map (void) 
  153.       : __t(Compare(), false, Allocator()) {}
  154.  
  155.     _EXPLICIT map (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  156.       : __t(comp, false, Allocator()) {}
  157. #endif
  158.  
  159. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  160.     template<class InputIterator>
  161.     map (InputIterator first, InputIterator last, 
  162.          const Compare& comp = Compare(),
  163.          const Allocator& alloc = Allocator())
  164.       : __t(first, last, comp, false, alloc) {}
  165. #else
  166.     map (const value_type* first, const value_type* last, 
  167.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  168.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  169.       : __t(first, last, comp, false, alloc) {}
  170.     map (iterator first, iterator last, 
  171.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  172.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  173.       : __t(first, last, comp, false, alloc) {}
  174.     map (const_iterator first, const_iterator last, 
  175.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  176.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  177.       : __t(first, last, comp, false, alloc) {}
  178. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  179.     map (const value_type* first, const value_type* last)
  180.       : __t(first, last, Compare(), false, Allocator()) {}
  181.     map (const value_type* first, const value_type* last, 
  182.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  183.       : __t(first, last, comp, false, Allocator()) {}
  184.  
  185.     map (iterator first, iterator last)
  186.       : __t(first, last, Compare(), false, Allocator()) {}
  187.     map (iterator first, iterator last, 
  188.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  189.       : __t(first, last, comp, false, Allocator()) {}
  190.  
  191.     map (const_iterator first, const_iterator last) : __t(first, last, Compare(), false, Allocator()) {}
  192.     map (const_iterator first, const_iterator last, 
  193.          const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  194.       : __t(first, last, comp, false, Allocator()) {}
  195. #endif
  196. #endif
  197.  
  198.     map (const map<Key, T, Compare, Allocator>& x) : __t(x.__t, false) {}
  199.     map<Key, T, Compare, Allocator>& 
  200.     operator= (const map<Key, T, Compare, Allocator>& x)
  201.     {
  202.       __t = x.__t; return *this; 
  203.     }
  204.     allocator_type get_allocator() const
  205.     {
  206.       return __t.get_allocator();
  207.     }
  208.  
  209.     //
  210.     // iterators
  211.     //
  212.  
  213.     iterator               begin  ()       { return __t.begin();  }
  214.     const_iterator         begin  () const { return __t.begin();  }
  215.     iterator               end    ()       { return __t.end();    }
  216.     const_iterator         end    () const { return __t.end();    }
  217.     reverse_iterator       rbegin ()       { return __t.rbegin(); }
  218.     const_reverse_iterator rbegin () const { return __t.rbegin(); }
  219.     reverse_iterator       rend   ()       { return __t.rend();   }
  220.     const_reverse_iterator rend   () const { return __t.rend();   }
  221.  
  222.     //
  223.     // capacity
  224.     //
  225.     bool      empty    () const { return __t.empty();    }
  226.     size_type size     () const { return __t.size();     }
  227.     size_type max_size () const { return __t.max_size(); }
  228.  
  229.     //
  230.     // element access
  231.     //
  232.     mapped_type& operator[] (const key_type& k)
  233.     {
  234.       value_type tmp(k,T()); return (*((insert(tmp)).first)).second;
  235.     }
  236.  
  237. #ifndef _RWSTD_NO_RET_TEMPLATE
  238.     pair<iterator,bool> insert (const value_type& x) { return __t.insert(x); }
  239. #else
  240.     typedef pair<iterator, bool> pair_iterator_bool; 
  241.     //
  242.     // typedef done to get around compiler bug
  243.     //
  244.     pair_iterator_bool insert (const value_type& x) { return __t.insert(x); }
  245. #endif
  246.     iterator insert (iterator position, const value_type& x)
  247.     {
  248.       return __t.insert(position, x);
  249.     }
  250.  
  251. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  252.     template<class InputIterator>
  253.     void insert (InputIterator first, InputIterator last)
  254.     {
  255.       __t.insert(first, last);
  256.     }
  257. #else
  258.     void insert (const value_type* first, const value_type* last)
  259.     {
  260.       __t.insert(first, last);
  261.     }
  262.     void insert (iterator first, iterator last)
  263.     {
  264.       __t.insert(first, last);
  265.     }
  266.     void insert (const_iterator first, const_iterator last)
  267.     {
  268.       __t.insert(first, last);
  269.     }
  270. #endif
  271.  
  272.     void  erase (iterator position)             { __t.erase(position);}
  273.     size_type erase (const key_type& x)         { return __t.erase(x); }
  274.     void  erase (iterator first, iterator last) { __t.erase(first,last);}
  275.     void      swap  (map<Key, T, Compare, Allocator>& x)       
  276.     { __t.swap(x.__t);          }
  277.     void      clear ()                              { erase(begin(),end()); }
  278.  
  279.     //
  280.     // observers
  281.     //
  282.     key_compare key_comp () const { return __t.key_comp(); }
  283.     value_compare value_comp () const { return value_compare(__t.key_comp()); }
  284.  
  285.     //
  286.     // map operations
  287.     //
  288.     iterator     find (const key_type& x)        { return __t.find(x);}
  289.     const_iterator find (const key_type& x)  const { return __t.find(x); }
  290.     size_type    count (const key_type& x) const { return __t.count(x); }
  291.     iterator     lower_bound (const key_type& x) { return __t.lower_bound(x); }
  292.     iterator     upper_bound (const key_type& x) { return __t.upper_bound(x); }
  293.     const_iterator lower_bound (const key_type& x) const
  294.     {
  295.       return __t.lower_bound(x); 
  296.     }
  297.     const_iterator upper_bound (const key_type& x) const
  298.     {
  299.       return __t.upper_bound(x); 
  300.     }
  301. #ifndef _RWSTD_NO_RET_TEMPLATE
  302.     pair<iterator,iterator> equal_range (const key_type& x)
  303. #else
  304.       typedef pair<iterator, iterator> pair_iterator_iterator; 
  305.       //
  306.       // typedef done to get around compiler bug
  307.       //
  308.       pair_iterator_iterator equal_range (const key_type& x)
  309. #endif
  310.     {
  311.       return __t.equal_range(x);
  312.     }
  313. #ifndef _RWSTD_NO_RET_TEMPLATE
  314.     pair<const_iterator, const_iterator> equal_range (const key_type& x) const
  315. #else
  316.       typedef pair<const_iterator, const_iterator> pair_citerator_citerator; 
  317.     //
  318.     // typedef done to get around compiler bug
  319.     //
  320.     pair_citerator_citerator equal_range (const key_type& x) const
  321. #endif
  322.     {
  323.       return __t.equal_range(x);
  324.     }
  325.  
  326. #ifndef _RWSTD_STRICT_ANSI
  327.     // Non-standard function for setting buffer allocation size
  328.     size_type allocation_size() { return __t.allocation_size(); }
  329.     size_type allocation_size(size_type new_size) 
  330.     { 
  331.       return __t.allocation_size(new_size);
  332.     }
  333. #endif  
  334.   };
  335.  
  336. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES  
  337.   template <class Key, class T, class Compare = less<Key>, 
  338. #ifndef _RWSTD_NO_CONST_INST
  339.   class Allocator = allocator<pair<const Key,T> > >
  340. #else
  341.   class Allocator = allocator<pair<Key,T> > >
  342. #endif // _RWSTD_NO_CONST_INST
  343. #else
  344.   template <class Key, class T, class Compare, class Allocator>
  345. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  346.   class multimap
  347.   {
  348.   public:
  349.     //
  350.     // types
  351.     //
  352.     typedef Key                  key_type;
  353.     typedef T                    mapped_type;
  354. #ifndef _RWSTD_NO_CONST_INST
  355.     typedef pair<const Key, T>   value_type;
  356. #else
  357.     typedef pair<Key, T>         value_type;
  358. #endif
  359.     typedef Compare              key_compare;
  360.     typedef Allocator            allocator_type;
  361.  
  362.   private:
  363.     
  364.     typedef __RWSTD::__rb_tree<key_type, value_type, 
  365.     __RWSTD::__select1st<value_type, key_type>, 
  366.     key_compare, allocator_type> __rep_type;
  367.     __rep_type __t;
  368.  
  369.   public:
  370.     //
  371.     // types
  372.     //
  373.     typedef _TYPENAME __rep_type::reference                reference;
  374.     typedef _TYPENAME __rep_type::const_reference          const_reference;
  375.     typedef _TYPENAME __rep_type::iterator                 iterator;
  376.     typedef _TYPENAME __rep_type::const_iterator           const_iterator; 
  377.     typedef _TYPENAME __rep_type::size_type                size_type;
  378.     typedef _TYPENAME __rep_type::difference_type          difference_type;
  379.     typedef _TYPENAME __rep_type::pointer                  pointer;
  380.     typedef _TYPENAME __rep_type::const_pointer            const_pointer; 
  381.     typedef _TYPENAME __rep_type::reverse_iterator         reverse_iterator;
  382.     typedef _TYPENAME __rep_type::const_reverse_iterator   const_reverse_iterator;
  383.  
  384.     class value_compare : public binary_function<value_type, value_type, bool>
  385.     {
  386.       friend class multimap<Key, T, Compare, Allocator>;
  387.     protected:
  388.       Compare comp;
  389.       value_compare (Compare c) : comp(c) {}
  390.     public:
  391.       bool operator() (const value_type& x, const value_type& y) const
  392.       {
  393.         return comp(x.first, y.first);
  394.       }
  395.     };
  396.  
  397.     //
  398.     // construct/copy/destroy
  399.     //
  400.     _EXPLICIT multimap (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  401.                         const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) 
  402.       : __t(comp, true, alloc) { }
  403.  
  404. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  405.     multimap (void) 
  406.       : t(Compare(), true, Allocator()) { }
  407.     _EXPLICIT multimap (const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  408.       : __t(comp, true, Allocator()) { }
  409. #endif
  410.  
  411. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  412.     template<class InputIterator>
  413.     multimap (InputIterator first, InputIterator last, 
  414.               const Compare& comp = Compare(),
  415.               const Allocator& alloc = Allocator()) 
  416.       : __t(first, last, comp, true, alloc) { }
  417. #else
  418.     multimap (const value_type* first, const value_type* last, 
  419.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  420.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  421.       : __t(first, last, comp, true, alloc) { }
  422.     multimap (iterator first, iterator last,
  423.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  424.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  425.       : __t(first, last, comp, true, alloc) { }
  426.     multimap (const_iterator first, const_iterator last,
  427.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()),
  428.               const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  429.       : __t(first, last, comp, true, alloc) { }
  430. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  431.     multimap (const value_type* first, const value_type* last)
  432.       : __t(first, last, Compare(), true, Allocator()) { }
  433.     multimap (const value_type* first, const value_type* last, 
  434.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  435.       : __t(first, last, comp, true, Allocator()) { }
  436.  
  437.     multimap (iterator first, iterator last)
  438.       : __t(first, last, Compare(), true, Allocator()) { }
  439.     multimap (iterator first, iterator last,
  440.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  441.       : __t(first, last, comp, true, Allocator()) { }
  442.  
  443.     multimap (const_iterator first, const_iterator last)
  444.       : __t(first, last, Compare(), true, Allocator()) { }
  445.     multimap (const_iterator first, const_iterator last,
  446.               const Compare& comp _RWSTD_DEFAULT_ARG(Compare()))
  447.       : __t(first, last, comp, true, Allocator()) { }
  448. #endif
  449. #endif
  450.  
  451.     multimap (const multimap<Key, T, Compare, Allocator>& x) : __t(x.__t, true) { }
  452.     multimap<Key, T, Compare, Allocator>& 
  453.     operator= (const multimap<Key, T, Compare, Allocator>& x)
  454.     {
  455.       __t = x.__t; return *this; 
  456.     }
  457.     allocator_type get_allocator() const
  458.     {
  459.       return __t.get_allocator();
  460.     }
  461.  
  462.     //
  463.     // iterators
  464.     //
  465.     iterator                 begin  ()       { return __t.begin();  }
  466.     const_iterator           begin  () const { return __t.begin();  }
  467.     iterator                 end    ()       { return __t.end();    }
  468.     const_iterator           end    () const { return __t.end();    }
  469.     reverse_iterator         rbegin ()       { return __t.rbegin(); }
  470.     const_reverse_iterator   rbegin () const { return __t.rbegin(); }
  471.     reverse_iterator         rend   ()       { return __t.rend();   }
  472.     const_reverse_iterator   rend   () const { return __t.rend();   }
  473.  
  474.     //
  475.     // capacity
  476.     //
  477.     bool        empty   () const { return __t.empty();    }
  478.     size_type   size    () const { return __t.size();     }
  479.     size_type   max_size() const { return __t.max_size(); }
  480.  
  481.     //
  482.     // modifiers
  483.     //
  484.     iterator insert (const value_type& x) { return __t.insert(x).first; }
  485.     iterator insert (iterator position, const value_type& x)
  486.     {
  487.       return __t.insert(position, x);
  488.     }
  489.  
  490. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  491.     template<class InputIterator>
  492.     void insert (InputIterator first, InputIterator last)
  493.     {
  494.       __t.insert(first, last);
  495.     }
  496. #else
  497.     void insert (const value_type* first, const value_type* last)
  498.     {
  499.       __t.insert(first, last);
  500.     }
  501.     void insert (iterator first, iterator last)
  502.     {
  503.       __t.insert(first, last);
  504.     }
  505.     void insert (const_iterator first, const_iterator last)
  506.     {
  507.       __t.insert(first, last);
  508.     }
  509. #endif
  510.  
  511.     void  erase (iterator position)             { __t.erase(position); }
  512.     size_type erase (const key_type& x)         { return __t.erase(x);    }
  513.     void  erase (iterator first, iterator last) { __t.erase(first, last); }
  514.     void      clear ()                          { erase(begin(),end()); }
  515.     void      swap  (multimap<Key, T, Compare, Allocator>& x)  
  516.     { __t.swap(x.__t);          }
  517.  
  518.     //
  519.     // observers
  520.     //
  521.     key_compare   key_comp   () const { return __t.key_comp();                }
  522.     value_compare value_comp () const { return value_compare(__t.key_comp()); }
  523.  
  524.     //
  525.     // map operations
  526.     //
  527.     iterator    find (const key_type& x)        { return __t.find(x); }
  528.     const_iterator  find (const key_type& x)  const { return __t.find(x); }
  529.     size_type   count (const key_type& x) const { return __t.count(x); }
  530.     iterator    lower_bound (const key_type& x) {return __t.lower_bound(x);}
  531.     iterator    upper_bound (const key_type& x) {return __t.upper_bound(x);}
  532.     const_iterator  lower_bound (const key_type& x) const
  533.     {
  534.       return __t.lower_bound(x); 
  535.     }
  536.     const_iterator  upper_bound (const key_type& x) const
  537.     {
  538.       return __t.upper_bound(x); 
  539.     }
  540. #ifndef _RWSTD_NO_RET_TEMPLATE
  541.     pair<iterator,iterator> equal_range (const key_type& x)
  542. #else
  543.       typedef  pair<iterator, iterator> pair_iterator_iterator; 
  544.       //
  545.       // typedef done to get around compiler bug
  546.       //
  547.       pair_iterator_iterator equal_range (const key_type& x)
  548. #endif
  549.     {
  550.       return __t.equal_range(x);
  551.     }
  552. #ifndef _RWSTD_NO_RET_TEMPLATE
  553.     pair<const_iterator,const_iterator> equal_range (const key_type& x) const
  554. #else
  555.       typedef  pair<const_iterator, const_iterator> pair_citerator_citerator; 
  556.     //
  557.     // typedef done to get around compiler bug
  558.     //
  559.     pair_citerator_citerator equal_range (const key_type& x) const
  560. #endif
  561.     {
  562.       return __t.equal_range(x);
  563.     }
  564.  
  565. #ifndef _RWSTD_STRICT_ANSI
  566.     // Non-standard function for setting buffer allocation size
  567.     size_type allocation_size() { return __t.allocation_size(); }
  568.     size_type allocation_size(size_type new_size) 
  569.     { 
  570.       return __t.allocation_size(new_size);
  571.     }
  572. #endif  
  573.   };
  574.  
  575.   template <class Key, class T, class Compare, class Allocator>
  576.   inline bool operator== (const map<Key, T, Compare, Allocator>& x,
  577.                           const map<Key, T, Compare, Allocator>& y)
  578.   {
  579.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  580.   }
  581.  
  582.   template <class Key, class T, class Compare, class Allocator>
  583.   inline bool operator< (const map<Key, T, Compare, Allocator>& x, 
  584.                          const map<Key, T, Compare, Allocator>& y)
  585.   {
  586.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  587.   }
  588.  
  589. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  590.   template <class Key, class T, class Compare, class Allocator>
  591.   inline bool operator!= (const map<Key,T,Compare,Allocator>& x, 
  592.                           const map<Key,T,Compare,Allocator>& y)
  593.   {
  594.     return !(x == y);
  595.   }
  596.  
  597.   template <class Key, class T, class Compare, class Allocator>
  598.   inline bool operator> (const map<Key,T,Compare,Allocator>& x, 
  599.                          const map<Key,T,Compare,Allocator>& y)
  600.   {
  601.     return y < x;
  602.   }
  603.  
  604.   template <class Key, class T, class Compare, class Allocator>
  605.   inline bool operator>= (const map<Key,T,Compare,Allocator>& x, 
  606.                           const map<Key,T,Compare,Allocator>& y)
  607.   {
  608.     return !(x < y);
  609.   }
  610.  
  611.   template <class Key, class T, class Compare, class Allocator>
  612.   inline bool operator<= (const map<Key,T,Compare,Allocator>& x, 
  613.                           const map<Key,T,Compare,Allocator>& y)
  614.   {
  615.     return !(y <  x);
  616.   }
  617.  
  618.   template <class Key, class T, class Compare, class Allocator>
  619.   void swap(map<Key,T,Compare,Allocator>& a, 
  620.             map<Key,T,Compare,Allocator>& b)
  621.   {
  622.     a.swap(b);
  623.   }
  624. #endif
  625.  
  626.   template <class Key, class T, class Compare, class Allocator>
  627.   inline bool operator== (const multimap<Key, T, Compare, Allocator>& x, 
  628.                           const multimap<Key, T, Compare, Allocator>& y)
  629.   {
  630.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  631.   }
  632.  
  633.   template <class Key, class T, class Compare, class Allocator>
  634.   inline bool operator< (const multimap<Key, T, Compare, Allocator>& x, 
  635.                          const multimap<Key, T, Compare, Allocator>& y)
  636.   {
  637.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  638.   }
  639.  
  640. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  641.   template <class Key, class T, class Compare, class Allocator>
  642.   inline bool operator!= (const multimap<Key,T,Compare,Allocator>& x, 
  643.                           const multimap<Key,T,Compare,Allocator>& y)
  644.   {
  645.     return !(x == y);
  646.   }
  647.  
  648.   template <class Key, class T, class Compare, class Allocator>
  649.   inline bool operator> (const multimap<Key,T,Compare,Allocator>& x, 
  650.                          const multimap<Key,T,Compare,Allocator>& y)
  651.   {
  652.     return y < x;
  653.   }
  654.  
  655.   template <class Key, class T, class Compare, class Allocator>
  656.   inline bool operator>= (const multimap<Key,T,Compare,Allocator>& x, 
  657.                           const multimap<Key,T,Compare,Allocator>& y)
  658.   {
  659.     return !(x < y);
  660.   }
  661.  
  662.   template <class Key, class T, class Compare, class Allocator>
  663.   inline bool operator<= (const multimap<Key,T,Compare,Allocator>& x, 
  664.                           const multimap<Key,T,Compare,Allocator>& y)
  665.   {
  666.     return !(y <  x);
  667.   }
  668.  
  669.   template <class Key, class T, class Compare, class Allocator>
  670.   void swap(multimap<Key,T,Compare,Allocator>& a, 
  671.             multimap<Key,T,Compare,Allocator>& b)
  672.   {
  673.     a.swap(b);
  674.   }
  675. #endif
  676.  
  677. #ifndef _RWSTD_NO_NAMESPACE
  678. }
  679. #endif
  680.  
  681. #endif
  682.  
  683. #ifndef __USING_STD_NAMES__
  684.   using namespace std;
  685. #endif
  686.  
  687. #pragma option pop
  688. #endif /* __MAP_H */
  689.