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