stl_map.h

Go to the documentation of this file.
00001 // Map implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /*
00031  *
00032  * Copyright (c) 1994
00033  * Hewlett-Packard Company
00034  *
00035  * Permission to use, copy, modify, distribute and sell this software
00036  * and its documentation for any purpose is hereby granted without fee,
00037  * provided that the above copyright notice appear in all copies and
00038  * that both that copyright notice and this permission notice appear
00039  * in supporting documentation.  Hewlett-Packard Company makes no
00040  * representations about the suitability of this software for any
00041  * purpose.  It is provided "as is" without express or implied warranty.
00042  *
00043  *
00044  * Copyright (c) 1996,1997
00045  * Silicon Graphics Computer Systems, Inc.
00046  *
00047  * Permission to use, copy, modify, distribute and sell this software
00048  * and its documentation for any purpose is hereby granted without fee,
00049  * provided that the above copyright notice appear in all copies and
00050  * that both that copyright notice and this permission notice appear
00051  * in supporting documentation.  Silicon Graphics makes no
00052  * representations about the suitability of this software for any
00053  * purpose.  It is provided "as is" without express or implied warranty.
00054  */
00055 
00056 /** @file stl_map.h
00057  *  This is an internal header file, included by other library headers.
00058  *  You should not attempt to use it directly.
00059  */
00060 
00061 #ifndef __GLIBCPP_INTERNAL_MAP_H
00062 #define __GLIBCPP_INTERNAL_MAP_H
00063 
00064 #include <bits/concept_check.h>
00065 
00066 namespace std
00067 {
00068   /**
00069    *  @brief A standard container made up of (key,value) pairs, which can be
00070    *  retrieved based on a key, in logarithmic time.
00071    *
00072    *  @ingroup Containers
00073    *  @ingroup Assoc_containers
00074    *
00075    *  Meets the requirements of a <a href="tables.html#65">container</a>, a
00076    *  <a href="tables.html#66">reversible container</a>, and an
00077    *  <a href="tables.html#69">associative container</a> (using unique keys).
00078    *  For a @c map<Key,T> the key_type is Key, the mapped_type is T, and the
00079    *  value_type is std::pair<const Key,T>.
00080    *
00081    *  Maps support bidirectional iterators.
00082    *
00083    *  @if maint
00084    *  The private tree data is declared exactly the same way for map and
00085    *  multimap; the distinction is made entirely in how the tree functions are
00086    *  called (*_unique versus *_equal, same as the standard).
00087    *  @endif
00088   */
00089   template <typename _Key, typename _Tp, typename _Compare = less<_Key>,
00090             typename _Alloc = allocator<pair<const _Key, _Tp> > >
00091     class map
00092   {
00093     // concept requirements
00094     __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
00095     __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
00096   
00097   public:
00098     typedef _Key                                          key_type;
00099     typedef _Tp                                           mapped_type;
00100     typedef pair<const _Key, _Tp>                         value_type;
00101     typedef _Compare                                      key_compare;
00102   
00103     class value_compare
00104       : public binary_function<value_type, value_type, bool>
00105       {
00106         friend class map<_Key,_Tp,_Compare,_Alloc>;
00107       protected:
00108         _Compare comp;
00109         value_compare(_Compare __c) : comp(__c) {}
00110       public:
00111         bool operator()(const value_type& __x, const value_type& __y) const
00112         { return comp(__x.first, __y.first); }
00113       };
00114   
00115   private:
00116     /// @if maint  This turns a red-black tree into a [multi]map.  @endif
00117     typedef _Rb_tree<key_type, value_type,
00118                      _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
00119     /// @if maint  The actual tree structure.  @endif
00120     _Rep_type _M_t;
00121   
00122   public:
00123     // many of these are specified differently in ISO, but the following are
00124     // "functionally equivalent"
00125     typedef typename _Rep_type::allocator_type            allocator_type;
00126     typedef typename _Rep_type::reference                 reference;
00127     typedef typename _Rep_type::const_reference           const_reference;
00128     typedef typename _Rep_type::iterator                  iterator;
00129     typedef typename _Rep_type::const_iterator            const_iterator;
00130     typedef typename _Rep_type::size_type                 size_type;
00131     typedef typename _Rep_type::difference_type           difference_type;
00132     typedef typename _Rep_type::pointer                   pointer;
00133     typedef typename _Rep_type::const_pointer             const_pointer;
00134     typedef typename _Rep_type::reverse_iterator          reverse_iterator;
00135     typedef typename _Rep_type::const_reverse_iterator    const_reverse_iterator;
00136   
00137   
00138     // [23.3.1.1] construct/copy/destroy
00139     // (get_allocator() is normally listed in this section, but seems to have
00140     // been accidentally omitted in the printed standard)
00141     /**
00142      *  @brief  Default constructor creates no elements.
00143     */
00144     map() : _M_t(_Compare(), allocator_type()) { }
00145   
00146     // for some reason this was made a separate function
00147     /**
00148      *  @brief  Default constructor creates no elements.
00149     */
00150     explicit
00151     map(const _Compare& __comp, const allocator_type& __a = allocator_type())
00152       : _M_t(__comp, __a) { }
00153   
00154     /**
00155      *  @brief  Map copy constructor.
00156      *  @param  x  A %map of identical element and allocator types.
00157      *
00158      *  The newly-created %map uses a copy of the allocation object used
00159      *  by @a x.
00160     */
00161     map(const map& __x)
00162       : _M_t(__x._M_t) { }
00163   
00164     /**
00165      *  @brief  Builds a %map from a range.
00166      *  @param  first  An input iterator.
00167      *  @param  last  An input iterator.
00168      *
00169      *  Create a %map consisting of copies of the elements from [first,last).
00170      *  This is linear in N if the range is already sorted, and NlogN
00171      *  otherwise (where N is distance(first,last)).
00172     */
00173     template <typename _InputIterator>
00174       map(_InputIterator __first, _InputIterator __last)
00175       : _M_t(_Compare(), allocator_type())
00176       { _M_t.insert_unique(__first, __last); }
00177   
00178     /**
00179      *  @brief  Builds a %map from a range.
00180      *  @param  first  An input iterator.
00181      *  @param  last  An input iterator.
00182      *  @param  comp  A comparison functor.
00183      *  @param  a  An allocator object.
00184      *
00185      *  Create a %map consisting of copies of the elements from [first,last).
00186      *  This is linear in N if the range is already sorted, and NlogN
00187      *  otherwise (where N is distance(first,last)).
00188     */
00189     template <typename _InputIterator>
00190       map(_InputIterator __first, _InputIterator __last,
00191           const _Compare& __comp, const allocator_type& __a = allocator_type())
00192       : _M_t(__comp, __a)
00193       { _M_t.insert_unique(__first, __last); }
00194   
00195     // FIXME There is no dtor declared, but we should have something generated
00196     // by Doxygen.  I don't know what tags to add to this paragraph to make
00197     // that happen:
00198     /**
00199      *  The dtor only erases the elements, and note that if the elements
00200      *  themselves are pointers, the pointed-to memory is not touched in any
00201      *  way.  Managing the pointer is the user's responsibilty.
00202     */
00203   
00204     /**
00205      *  @brief  Map assignment operator.
00206      *  @param  x  A %map of identical element and allocator types.
00207      *
00208      *  All the elements of @a x are copied, but unlike the copy constructor,
00209      *  the allocator object is not copied.
00210     */
00211     map&
00212     operator=(const map& __x)
00213     {
00214       _M_t = __x._M_t;
00215       return *this;
00216     }
00217   
00218     /// Get a copy of the memory allocation object.
00219     allocator_type
00220     get_allocator() const { return _M_t.get_allocator(); }
00221   
00222     // iterators
00223     /**
00224      *  Returns a read/write iterator that points to the first pair in the %map.
00225      *  Iteration is done in ascending order according to the keys.
00226     */
00227     iterator
00228     begin() { return _M_t.begin(); }
00229   
00230     /**
00231      *  Returns a read-only (constant) iterator that points to the first pair
00232      *  in the %map.  Iteration is done in ascending order according to the
00233      *  keys.
00234     */
00235     const_iterator
00236     begin() const { return _M_t.begin(); }
00237   
00238     /**
00239      *  Returns a read/write iterator that points one past the last pair in the
00240      *  %map.  Iteration is done in ascending order according to the keys.
00241     */
00242     iterator
00243     end() { return _M_t.end(); }
00244   
00245     /**
00246      *  Returns a read-only (constant) iterator that points one past the last
00247      *  pair in the %map.  Iteration is done in ascending order according to the
00248      *  keys.
00249     */
00250     const_iterator
00251     end() const { return _M_t.end(); }
00252   
00253     /**
00254      *  Returns a read/write reverse iterator that points to the last pair in
00255      *  the %map.  Iteration is done in descending order according to the keys.
00256     */
00257     reverse_iterator
00258     rbegin() { return _M_t.rbegin(); }
00259   
00260     /**
00261      *  Returns a read-only (constant) reverse iterator that points to the last
00262      *  pair in the %map.  Iteration is done in descending order according to
00263      *  the keys.
00264     */
00265     const_reverse_iterator
00266     rbegin() const { return _M_t.rbegin(); }
00267   
00268     /**
00269      *  Returns a read/write reverse iterator that points to one before the
00270      *  first pair in the %map.  Iteration is done in descending order according
00271      *  to the keys.
00272     */
00273     reverse_iterator
00274     rend() { return _M_t.rend(); }
00275   
00276     /**
00277      *  Returns a read-only (constant) reverse iterator that points to one
00278      *  before the first pair in the %map.  Iteration is done in descending
00279      *  order according to the keys.
00280     */
00281     const_reverse_iterator
00282     rend() const { return _M_t.rend(); }
00283   
00284     // capacity
00285     /** Returns true if the %map is empty.  (Thus begin() would equal end().) */
00286     bool
00287     empty() const { return _M_t.empty(); }
00288   
00289     /** Returns the size of the %map.  */
00290     size_type
00291     size() const { return _M_t.size(); }
00292   
00293     /** Returns the maximum size of the %map.  */
00294     size_type
00295     max_size() const { return _M_t.max_size(); }
00296   
00297     // [23.3.1.2] element access
00298     /**
00299      *  @brief  Subscript ( @c [] ) access to %map data.
00300      *  @param  k  The key for which data should be retrieved.
00301      *  @return  A reference to the data of the (key,data) %pair.
00302      *
00303      *  Allows for easy lookup with the subscript ( @c [] ) operator.  Returns
00304      *  data associated with the key specified in subscript.  If the key does
00305      *  not exist, a pair with that key is created using default values, which
00306      *  is then returned.
00307      *
00308      *  Lookup requires logarithmic time.
00309     */
00310     mapped_type&
00311     operator[](const key_type& __k)
00312     {
00313       // concept requirements
00314       __glibcpp_function_requires(_DefaultConstructibleConcept<mapped_type>)
00315   
00316       iterator __i = lower_bound(__k);
00317       // __i->first is greater than or equivalent to __k.
00318       if (__i == end() || key_comp()(__k, (*__i).first))
00319         __i = insert(__i, value_type(__k, mapped_type()));
00320       return (*__i).second;
00321     }
00322   
00323     // modifiers
00324     /**
00325      *  @brief Attempts to insert a std::pair into the %map.
00326      *  @param  x  Pair to be inserted (see std::make_pair for easy creation of
00327      *             pairs).
00328      *  @return  A pair, of which the first element is an iterator that points
00329      *           to the possibly inserted pair, and the second is a bool that
00330      *           is true if the pair was actually inserted.
00331      *
00332      *  This function attempts to insert a (key, value) %pair into the %map.
00333      *  A %map relies on unique keys and thus a %pair is only inserted if its
00334      *  first element (the key) is not already present in the %map.
00335      *
00336      *  Insertion requires logarithmic time.
00337     */
00338     pair<iterator,bool>
00339     insert(const value_type& __x)
00340     { return _M_t.insert_unique(__x); }
00341   
00342     /**
00343      *  @brief Attempts to insert a std::pair into the %map.
00344      *  @param  position  An iterator that serves as a hint as to where the
00345      *                    pair should be inserted.
00346      *  @param  x  Pair to be inserted (see std::make_pair for easy creation of
00347      *             pairs).
00348      *  @return  An iterator that points to the element with key of @a x (may
00349      *           or may not be the %pair passed in).
00350      *
00351      *  This function is not concerned about whether the insertion took place,
00352      *  and thus does not return a boolean like the single-argument
00353      *  insert() does.  Note that the first parameter is only a hint and can
00354      *  potentially improve the performance of the insertion process.  A bad
00355      *  hint would cause no gains in efficiency.
00356      *
00357      *  See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
00358      *  for more on "hinting".
00359      *
00360      *  Insertion requires logarithmic time (if the hint is not taken).
00361     */
00362     iterator
00363     insert(iterator position, const value_type& __x)
00364     { return _M_t.insert_unique(position, __x); }
00365   
00366     /**
00367      *  @brief A template function that attemps to insert a range of elements.
00368      *  @param  first  Iterator pointing to the start of the range to be
00369      *                 inserted.
00370      *  @param  last  Iterator pointing to the end of the range.
00371      *
00372      *  Complexity similar to that of the range constructor.
00373     */
00374     template <typename _InputIterator>
00375       void
00376       insert(_InputIterator __first, _InputIterator __last)
00377       { _M_t.insert_unique(__first, __last); }
00378   
00379     /**
00380      *  @brief Erases an element from a %map.
00381      *  @param  position  An iterator pointing to the element to be erased.
00382      *
00383      *  This function erases an element, pointed to by the given iterator, from
00384      *  a %map.  Note that this function only erases the element, and that if
00385      *  the element is itself a pointer, the pointed-to memory is not touched
00386      *  in any way.  Managing the pointer is the user's responsibilty.
00387     */
00388     void
00389     erase(iterator __position) { _M_t.erase(__position); }
00390   
00391     /**
00392      *  @brief Erases elements according to the provided key.
00393      *  @param  x  Key of element to be erased.
00394      *  @return  The number of elements erased.
00395      *
00396      *  This function erases all the elements located by the given key from
00397      *  a %map.
00398      *  Note that this function only erases the element, and that if
00399      *  the element is itself a pointer, the pointed-to memory is not touched
00400      *  in any way.  Managing the pointer is the user's responsibilty.
00401     */
00402     size_type
00403     erase(const key_type& __x) { return _M_t.erase(__x); }
00404   
00405     /**
00406      *  @brief Erases a [first,last) range of elements from a %map.
00407      *  @param  first  Iterator pointing to the start of the range to be erased.
00408      *  @param  last  Iterator pointing to the end of the range to be erased.
00409      *
00410      *  This function erases a sequence of elements from a %map.
00411      *  Note that this function only erases the element, and that if
00412      *  the element is itself a pointer, the pointed-to memory is not touched
00413      *  in any way.  Managing the pointer is the user's responsibilty.
00414     */
00415     void
00416     erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
00417   
00418     /**
00419      *  @brief  Swaps data with another %map.
00420      *  @param  x  A %map of the same element and allocator types.
00421      *
00422      *  This exchanges the elements between two maps in constant time.
00423      *  (It is only swapping a pointer, an integer, and an instance of
00424      *  the @c Compare type (which itself is often stateless and empty), so it
00425      *  should be quite fast.)
00426      *  Note that the global std::swap() function is specialized such that
00427      *  std::swap(m1,m2) will feed to this function.
00428     */
00429     void
00430     swap(map& __x) { _M_t.swap(__x._M_t); }
00431   
00432     /**
00433      *  Erases all elements in a %map.  Note that this function only erases
00434      *  the elements, and that if the elements themselves are pointers, the
00435      *  pointed-to memory is not touched in any way.  Managing the pointer is
00436      *  the user's responsibilty.
00437     */
00438     void
00439     clear() { _M_t.clear(); }
00440   
00441     // observers
00442     /**
00443      *  Returns the key comparison object out of which the %map was constructed.
00444     */
00445     key_compare
00446     key_comp() const { return _M_t.key_comp(); }
00447   
00448     /**
00449      *  Returns a value comparison object, built from the key comparison
00450      *  object out of which the %map was constructed.
00451     */
00452     value_compare
00453     value_comp() const { return value_compare(_M_t.key_comp()); }
00454   
00455     // [23.3.1.3] map operations
00456     /**
00457      *  @brief Tries to locate an element in a %map.
00458      *  @param  x  Key of (key, value) %pair to be located.
00459      *  @return  Iterator pointing to sought-after element, or end() if not
00460      *           found.
00461      *
00462      *  This function takes a key and tries to locate the element with which
00463      *  the key matches.  If successful the function returns an iterator
00464      *  pointing to the sought after %pair.  If unsuccessful it returns the
00465      *  past-the-end ( @c end() ) iterator.
00466     */
00467     iterator
00468     find(const key_type& __x) { return _M_t.find(__x); }
00469   
00470     /**
00471      *  @brief Tries to locate an element in a %map.
00472      *  @param  x  Key of (key, value) %pair to be located.
00473      *  @return  Read-only (constant) iterator pointing to sought-after
00474      *           element, or end() if not found.
00475      *
00476      *  This function takes a key and tries to locate the element with which
00477      *  the key matches.  If successful the function returns a constant iterator
00478      *  pointing to the sought after %pair. If unsuccessful it returns the
00479      *  past-the-end ( @c end() ) iterator.
00480     */
00481     const_iterator
00482     find(const key_type& __x) const { return _M_t.find(__x); }
00483   
00484     /**
00485      *  @brief  Finds the number of elements with given key.
00486      *  @param  x  Key of (key, value) pairs to be located.
00487      *  @return  Number of elements with specified key.
00488      *
00489      *  This function only makes sense for multimaps; for map the result will
00490      *  either be 0 (not present) or 1 (present).
00491     */
00492     size_type
00493     count(const key_type& __x) const
00494     { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
00495   
00496     /**
00497      *  @brief Finds the beginning of a subsequence matching given key.
00498      *  @param  x  Key of (key, value) pair to be located.
00499      *  @return  Iterator pointing to first element matching given key, or
00500      *           end() if not found.
00501      *
00502      *  This function is useful only with multimaps.  It returns the first
00503      *  element of a subsequence of elements that matches the given key.  If
00504      *  unsuccessful it returns an iterator pointing to the first element that
00505      *  has a greater value than given key or end() if no such element exists.
00506     */
00507     iterator
00508     lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); }
00509   
00510     /**
00511      *  @brief Finds the beginning of a subsequence matching given key.
00512      *  @param  x  Key of (key, value) pair to be located.
00513      *  @return  Read-only (constant) iterator pointing to first element
00514      *           matching given key, or end() if not found.
00515      *
00516      *  This function is useful only with multimaps.  It returns the first
00517      *  element of a subsequence of elements that matches the given key.  If
00518      *  unsuccessful the iterator will point to the next greatest element or,
00519      *  if no such greater element exists, to end().
00520     */
00521     const_iterator
00522     lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); }
00523   
00524     /**
00525      *  @brief Finds the end of a subsequence matching given key.
00526      *  @param  x  Key of (key, value) pair to be located.
00527      *  @return Iterator pointing to last element matching given key.
00528      *
00529      *  This function only makes sense with multimaps.
00530     */
00531     iterator
00532     upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); }
00533   
00534     /**
00535      *  @brief Finds the end of a subsequence matching given key.
00536      *  @param  x  Key of (key, value) pair to be located.
00537      *  @return  Read-only (constant) iterator pointing to last element matching
00538      *           given key.
00539      *
00540      *  This function only makes sense with multimaps.
00541     */
00542     const_iterator
00543     upper_bound(const key_type& __x) const
00544     { return _M_t.upper_bound(__x); }
00545   
00546     /**
00547      *  @brief Finds a subsequence matching given key.
00548      *  @param  x  Key of (key, value) pairs to be located.
00549      *  @return  Pair of iterators that possibly points to the subsequence
00550      *           matching given key.
00551      *
00552      *  This function returns a pair of which the first
00553      *  element possibly points to the first element matching the given key
00554      *  and the second element possibly points to the last element matching the
00555      *  given key.  If unsuccessful the first element of the returned pair will
00556      *  contain an iterator pointing to the next greatest element or, if no such
00557      *  greater element exists, to end().
00558      *
00559      *  This function only makes sense for multimaps.
00560     */
00561     pair<iterator,iterator>
00562     equal_range(const key_type& __x)
00563     { return _M_t.equal_range(__x); }
00564   
00565     /**
00566      *  @brief Finds a subsequence matching given key.
00567      *  @param  x  Key of (key, value) pairs to be located.
00568      *  @return  Pair of read-only (constant) iterators that possibly points to
00569      *           the subsequence matching given key.
00570      *
00571      *  This function returns a pair of which the first
00572      *  element possibly points to the first element matching the given key
00573      *  and the second element possibly points to the last element matching the
00574      *  given key.  If unsuccessful the first element of the returned pair will
00575      *  contain an iterator pointing to the next greatest element or, if no such
00576      *  a greater element exists, to end().
00577      *
00578      *  This function only makes sense for multimaps.
00579     */
00580     pair<const_iterator,const_iterator>
00581     equal_range(const key_type& __x) const
00582     { return _M_t.equal_range(__x); }
00583   
00584     template <typename _K1, typename _T1, typename _C1, typename _A1>
00585     friend bool operator== (const map<_K1,_T1,_C1,_A1>&,
00586                             const map<_K1,_T1,_C1,_A1>&);
00587     template <typename _K1, typename _T1, typename _C1, typename _A1>
00588     friend bool operator< (const map<_K1,_T1,_C1,_A1>&,
00589                            const map<_K1,_T1,_C1,_A1>&);
00590   };
00591   
00592   
00593   /**
00594    *  @brief  Map equality comparison.
00595    *  @param  x  A %map.
00596    *  @param  y  A %map of the same type as @a x.
00597    *  @return  True iff the size and elements of the maps are equal.
00598    *
00599    *  This is an equivalence relation.  It is linear in the size of the
00600    *  maps.  Maps are considered equivalent if their sizes are equal,
00601    *  and if corresponding elements compare equal.
00602   */
00603   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00604     inline bool
00605     operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00606                const map<_Key,_Tp,_Compare,_Alloc>& __y)
00607     { return __x._M_t == __y._M_t; }
00608   
00609   /**
00610    *  @brief  Map ordering relation.
00611    *  @param  x  A %map.
00612    *  @param  y  A %map of the same type as @a x.
00613    *  @return  True iff @a x is lexographically less than @a y.
00614    *
00615    *  This is a total ordering relation.  It is linear in the size of the
00616    *  maps.  The elements must be comparable with @c <.
00617    *
00618    *  See std::lexographical_compare() for how the determination is made.
00619   */
00620   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00621     inline bool
00622     operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00623               const map<_Key,_Tp,_Compare,_Alloc>& __y)
00624     { return __x._M_t < __y._M_t; }
00625   
00626   /// Based on operator==
00627   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00628     inline bool
00629     operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00630                const map<_Key,_Tp,_Compare,_Alloc>& __y)
00631     { return !(__x == __y); }
00632   
00633   /// Based on operator<
00634   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00635     inline bool
00636     operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00637               const map<_Key,_Tp,_Compare,_Alloc>& __y)
00638     { return __y < __x; }
00639   
00640   /// Based on operator<
00641   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00642     inline bool
00643     operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00644                const map<_Key,_Tp,_Compare,_Alloc>& __y)
00645     { return !(__y < __x); }
00646   
00647   /// Based on operator<
00648   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00649     inline bool
00650     operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
00651                const map<_Key,_Tp,_Compare,_Alloc>& __y)
00652     { return !(__x < __y); }
00653   
00654   /// See std::map::swap().
00655   template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
00656     inline void
00657     swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y)
00658     { __x.swap(__y); }
00659 } // namespace std
00660 
00661 #endif /* __GLIBCPP_INTERNAL_MAP_H */

Generated on Thu Feb 10 23:22:59 2005 for libstdc++-v3 Source by  doxygen 1.4.0