OSDN Git Service

2002-06-21 Phil Edwards <pme@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / stl_map.h
1 // Map implementation -*- C++ -*-
2
3 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 /*
31  *
32  * Copyright (c) 1994
33  * Hewlett-Packard Company
34  *
35  * Permission to use, copy, modify, distribute and sell this software
36  * and its documentation for any purpose is hereby granted without fee,
37  * provided that the above copyright notice appear in all copies and
38  * that both that copyright notice and this permission notice appear
39  * in supporting documentation.  Hewlett-Packard Company makes no
40  * representations about the suitability of this software for any
41  * purpose.  It is provided "as is" without express or implied warranty.
42  *
43  *
44  * Copyright (c) 1996,1997
45  * Silicon Graphics Computer Systems, Inc.
46  *
47  * Permission to use, copy, modify, distribute and sell this software
48  * and its documentation for any purpose is hereby granted without fee,
49  * provided that the above copyright notice appear in all copies and
50  * that both that copyright notice and this permission notice appear
51  * in supporting documentation.  Silicon Graphics makes no
52  * representations about the suitability of this software for any
53  * purpose.  It is provided "as is" without express or implied warranty.
54  */
55
56 /** @file stl_map.h
57  *  This is an internal header file, included by other library headers.
58  *  You should not attempt to use it directly.
59  */
60
61 #ifndef __GLIBCPP_INTERNAL_MAP_H
62 #define __GLIBCPP_INTERNAL_MAP_H
63
64 #include <bits/concept_check.h>
65
66 // Since this entire file is within namespace std, there's no reason to
67 // waste two spaces along the left column.  Thus the leading indentation is
68 // slightly violated from here on.
69 namespace std
70 {
71
72 /**
73  *  @brief A standard container made up of (key,value) pairs, which can be
74  *  retrieved based on a key, in logarithmic time.
75  *
76  *  @ingroup Containers
77  *  @ingroup Assoc_containers
78  *
79  *  Meets the requirements of a <a href="tables.html#65">container</a>, a
80  *  <a href="tables.html#66">reversible container</a>, and an
81  *  <a href="tables.html#69">associative container</a> (using unique keys).
82  *  For a @c map<Key,T> the key_type is Key, the mapped_type is T, and the
83  *  value_type is std::pair<const Key,T>.
84  *
85  *  Maps support bidirectional iterators.
86  *
87  *  @if maint
88  *  The private tree data is declared exactly the same way for map and
89  *  multimap; the distinction is made entirely in how the tree functions are
90  *  called (*_unique versus *_equal, same as the standard).
91  *  @endif
92 */
93 template <typename _Key, typename _Tp, typename _Compare = less<_Key>,
94           typename _Alloc = allocator<pair<const _Key, _Tp> > >
95   class map
96 {
97   // concept requirements
98   __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
99   __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
100
101 public:
102   typedef _Key                                          key_type;
103   typedef _Tp                                           mapped_type;
104   typedef pair<const _Key, _Tp>                         value_type;
105   typedef _Compare                                      key_compare;
106
107   class value_compare
108     : public binary_function<value_type, value_type, bool>
109     {
110       friend class map<_Key,_Tp,_Compare,_Alloc>;
111     protected:
112       _Compare comp;
113       value_compare(_Compare __c) : comp(__c) {}
114     public:
115       bool operator()(const value_type& __x, const value_type& __y) const
116         { return comp(__x.first, __y.first); }
117     };
118
119 private:
120   /// @if maint  This turns a red-black tree into a [multi]map.  @endif
121   typedef _Rb_tree<key_type, value_type,
122                    _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
123   /// @if maint  The actual tree structure.  @endif
124   _Rep_type _M_t;
125
126 public:
127   // many of these are specified differently in ISO, but the following are
128   // "functionally equivalent"
129   typedef typename _Rep_type::allocator_type            allocator_type;
130   typedef typename _Rep_type::reference                 reference;
131   typedef typename _Rep_type::const_reference           const_reference;
132   typedef typename _Rep_type::iterator                  iterator;
133   typedef typename _Rep_type::const_iterator            const_iterator;
134   typedef typename _Rep_type::size_type                 size_type;
135   typedef typename _Rep_type::difference_type           difference_type;
136   typedef typename _Rep_type::pointer                   pointer;
137   typedef typename _Rep_type::const_pointer             const_pointer;
138   typedef typename _Rep_type::reverse_iterator          reverse_iterator;
139   typedef typename _Rep_type::const_reverse_iterator    const_reverse_iterator;
140
141
142   // [23.3.1.1] construct/copy/destroy
143   // (get_allocator() is normally listed in this section, but seems to have
144   // been accidentally omitted in the printed standard)
145   /**
146    *  @brief  Default constructor creates no elements.
147   */
148   map() : _M_t(_Compare(), allocator_type()) { }
149
150   // for some reason this was made a separate function
151   /**
152    *  @brief  Default constructor creates no elements.
153   */
154   explicit
155   map(const _Compare& __comp, const allocator_type& __a = allocator_type())
156     : _M_t(__comp, __a) { }
157
158   /**
159    *  @brief  Map copy constructor.
160    *  @param  x  A %map of identical element and allocator types.
161    *
162    *  The newly-created %map uses a copy of the allocation object used
163    *  by @a x.
164   */
165   map(const map& __x)
166     : _M_t(__x._M_t) { }
167
168   /**
169    *  @brief  Builds a %map from a range.
170    *  @param  first  An input iterator.
171    *  @param  last  An input iterator.
172    *
173    *  Creats a %map consisting of copies of the elements from [first,last).
174    *  This is linear in N if the range is already sorted, and NlogN
175    *  otherwise (where N is distance(first,last)).
176   */
177   template <typename _InputIterator>
178     map(_InputIterator __first, _InputIterator __last)
179     : _M_t(_Compare(), allocator_type())
180     { _M_t.insert_unique(__first, __last); }
181
182   /**
183    *  @brief  Builds a %map from a range.
184    *  @param  first  An input iterator.
185    *  @param  last  An input iterator.
186    *  @param  comp  A comparison functor.
187    *  @param  a  An allocator object.
188    *
189    *  Creats a %map consisting of copies of the elements from [first,last).
190    *  This is linear in N if the range is already sorted, and NlogN
191    *  otherwise (where N is distance(first,last)).
192   */
193   template <typename _InputIterator>
194     map(_InputIterator __first, _InputIterator __last,
195         const _Compare& __comp, const allocator_type& __a = allocator_type())
196     : _M_t(__comp, __a)
197     { _M_t.insert_unique(__first, __last); }
198
199   // FIXME There is no dtor declared, but we should have something generated
200   // by Doxygen.  I don't know what tags to add to this paragraph to make
201   // that happen:
202   /**
203    *  The dtor only erases the elements, and note that if the elements
204    *  themselves are pointers, the pointed-to memory is not touched in any
205    *  way.  Managing the pointer is the user's responsibilty.
206   */
207
208   /**
209    *  @brief  Map assignment operator.
210    *  @param  x  A %map of identical element and allocator types.
211    *
212    *  All the elements of @a x are copied, but unlike the copy constructor, the
213    *  allocator object is not copied.
214   */
215   map&
216   operator=(const map& __x)
217   {
218     _M_t = __x._M_t;
219     return *this;
220   }
221
222   /// Get a copy of the memory allocation object.
223   allocator_type
224   get_allocator() const { return _M_t.get_allocator(); }
225
226   // iterators
227   /**
228    *  Returns a read/write iterator that points to the first pair in the %map.
229    *  Iteration is done in ascending order according to the keys.
230   */
231   iterator
232   begin() { return _M_t.begin(); }
233
234   /**
235    *  Returns a read-only (constant) iterator that points to the first pair
236    *  in the %map.  Iteration is done in ascending order according to the keys.
237   */
238   const_iterator
239   begin() const { return _M_t.begin(); }
240
241   /**
242    *  Returns a read/write iterator that points one past the last pair in the
243    *  %map.  Iteration is done in ascending order according to the keys.
244   */
245   iterator
246   end() { return _M_t.end(); }
247
248   /**
249    *  Returns a read-only (constant) iterator that points one past the last
250    *  pair in the %map.  Iteration is done in ascending order according to the
251    *  keys.
252   */
253   const_iterator
254   end() const { return _M_t.end(); }
255
256   /**
257    *  Returns a read/write reverse iterator that points to the last pair in
258    *  the %map.  Iteration is done in descending order according to the keys.
259   */
260   reverse_iterator
261   rbegin() { return _M_t.rbegin(); }
262
263   /**
264    *  Returns a read-only (constant) reverse iterator that points to the last
265    *  pair in the %map.  Iteration is done in descending order according to
266    *  the keys.
267   */
268   const_reverse_iterator
269   rbegin() const { return _M_t.rbegin(); }
270
271   /**
272    *  Returns a read/write reverse iterator that points to one before the
273    *  first pair in the %map.  Iteration is done in descending order according
274    *  to the keys.
275   */
276   reverse_iterator
277   rend() { return _M_t.rend(); }
278
279   /**
280    *  Returns a read-only (constant) reverse iterator that points to one
281    *  before the first pair in the %map.  Iteration is done in descending order
282    *  according to the keys.
283   */
284   const_reverse_iterator
285   rend() const { return _M_t.rend(); }
286
287   // capacity
288   /** Returns true if the %map is empty.  (Thus begin() would equal end().)  */
289   bool
290   empty() const { return _M_t.empty(); }
291
292   /** Returns the size of the %map.  */
293   size_type
294   size() const { return _M_t.size(); }
295
296   /** Returns the maximum size of the %map.  */
297   size_type
298   max_size() const { return _M_t.max_size(); }
299
300   // [23.3.1.2] element access
301   /**
302    *  @brief  Subscript ( @c [] ) access to %map data.
303    *  @param  k  The key for which data should be retrieved.
304    *  @return  A reference to the data of the (key,data) %pair.
305    *
306    *  Allows for easy lookup with the subscript ( @c [] ) operator.  Returns
307    *  data associated with the key specified in subscript.  If the key does
308    *  not exist, a pair with that key is created using default values, which
309    *  is then returned.
310    *
311    *  Lookup requires logarithmic time.
312   */
313   mapped_type&
314   operator[](const key_type& __k)
315   {
316     // concept requirements
317     __glibcpp_function_requires(_DefaultConstructibleConcept<mapped_type>)
318
319     iterator __i = lower_bound(__k);
320     // __i->first is greater than or equivalent to __k.
321     if (__i == end() || key_comp()(__k, (*__i).first))
322       __i = insert(__i, value_type(__k, mapped_type()));
323     return (*__i).second;
324   }
325
326   // modifiers
327   /**
328    *  @brief Attempts to insert a std::pair into the %map.
329    *  @param  x  Pair to be inserted (see std::make_pair for easy creation of
330    *             pairs).
331    *  @return  A pair, of which the first element is an iterator that points
332    *           to the possibly inserted pair, and the second is a bool that
333    *           is true if the pair was actually inserted.
334    *
335    *  This function attempts to insert a (key, value) %pair into the %map.  A
336    *  %map relies on unique keys and thus a %pair is only inserted if its first
337    *  element (the key) is not already present in the %map.
338    *
339    *  Insertion requires logarithmic time.
340   */
341   pair<iterator,bool>
342   insert(const value_type& __x)
343     { return _M_t.insert_unique(__x); }
344
345   /**
346    *  @brief Attempts to insert a std::pair into the %map.
347    *  @param  position  An iterator that serves as a hint as to where the
348    *                    pair should be inserted.
349    *  @param  x  Pair to be inserted (see std::make_pair for easy creation of
350    *             pairs).
351    *  @return  An iterator that points to the element with key of @a x (may
352    *           or may not be the %pair passed in).
353    *
354    *  This function is not concerned about whether the insertion took place,
355    *  and thus does not return a boolean like the single-argument
356    *  insert() does.  Note that the first parameter is only a hint and can
357    *  potentially improve the performance of the insertion process.  A bad
358    *  hint would cause no gains in efficiency.
359    *
360    *  See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
361    *  for more on "hinting".
362    *
363    *  Insertion requires logarithmic time (if the hint is not taken).
364   */
365   iterator
366   insert(iterator position, const value_type& __x)
367     { return _M_t.insert_unique(position, __x); }
368
369   /**
370    *  @brief A template function that attemps to insert a range of elements.
371    *  @param  first  Iterator pointing to the start of the range to be inserted.
372    *  @param  last  Iterator pointing to the end of the range.
373    *
374    *  Complexity similar to that of the range constructor.
375   */
376   template <typename _InputIterator>
377     void
378     insert(_InputIterator __first, _InputIterator __last)
379       { _M_t.insert_unique(__first, __last); }
380
381   /**
382    *  @brief Erases an element from a %map.
383    *  @param  position  An iterator pointing to the element to be erased.
384    *
385    *  This function erases an element, pointed to by the given iterator, from
386    *  a %map.  Note that this function only erases the element, and that if
387    *  the element is itself a pointer, the pointed-to memory is not touched
388    *  in any way.  Managing the pointer is the user's responsibilty.
389   */
390   void
391   erase(iterator __position) { _M_t.erase(__position); }
392
393   /**
394    *  @brief Erases elements according to the provided key.
395    *  @param  x  Key of element to be erased.
396    *  @return  The number of elements erased.
397    *
398    *  This function erases all the elements located by the given key from
399    *  a %map.
400    *  Note that this function only erases the element, and that if
401    *  the element is itself a pointer, the pointed-to memory is not touched
402    *  in any way.  Managing the pointer is the user's responsibilty.
403   */
404   size_type
405   erase(const key_type& __x) { return _M_t.erase(__x); }
406
407   /**
408    *  @brief Erases a [first,last) range of elements from a %map.
409    *  @param  first  Iterator pointing to the start of the range to be erased.
410    *  @param  last  Iterator pointing to the end of the range to be erased.
411    *
412    *  This function erases a sequence of elements from a %map.
413    *  Note that this function only erases the element, and that if
414    *  the element is itself a pointer, the pointed-to memory is not touched
415    *  in any way.  Managing the pointer is the user's responsibilty.
416   */
417   void
418   erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
419
420   /**
421    *  @brief  Swaps data with another %map.
422    *  @param  x  A %map of the same element and allocator types.
423    *
424    *  This exchanges the elements between two maps in constant time.
425    *  (It is only swapping a pointer, an integer, and an instance of
426    *  the @c Compare type (which itself is often stateless and empty), so it
427    *  should be quite fast.)
428    *  Note that the global std::swap() function is specialized such that
429    *  std::swap(m1,m2) will feed to this function.
430   */
431   void
432   swap(map& __x) { _M_t.swap(__x._M_t); }
433
434   /**
435    *  Erases all elements in a %map.  Note that this function only erases
436    *  the elements, and that if the elements themselves are pointers, the
437    *  pointed-to memory is not touched in any way.  Managing the pointer is
438    *  the user's responsibilty.
439   */
440   void
441   clear() { _M_t.clear(); }
442
443   // observers
444   /**
445    *  Returns the key comparison object out of which the %map was constructed.
446   */
447   key_compare
448   key_comp() const { return _M_t.key_comp(); }
449
450   /**
451    *  Returns a value comparison object, built from the key comparison
452    *  object out of which the %map was constructed.
453   */
454   value_compare
455   value_comp() const { return value_compare(_M_t.key_comp()); }
456
457   // [23.3.1.3] map operations
458   /**
459    *  @brief Tries to locate an element in a %map.
460    *  @param  x  Key of (key, value) %pair to be located.
461    *  @return  Iterator pointing to sought-after element, or end() if not
462    *           found.
463    *
464    *  This function takes a key and tries to locate the element with which
465    *  the key matches.  If successful the function returns an iterator
466    *  pointing to the sought after %pair.  If unsuccessful it returns the
467    *  past-the-end ( @c end() ) iterator.
468   */
469   iterator
470   find(const key_type& __x) { return _M_t.find(__x); }
471
472   /**
473    *  @brief Tries to locate an element in a %map.
474    *  @param  x  Key of (key, value) %pair to be located.
475    *  @return  Read-only (constant) iterator pointing to sought-after
476    *           element, or end() if not found.
477    *
478    *  This function takes a key and tries to locate the element with which
479    *  the key matches.  If successful the function returns a constant iterator
480    *  pointing to the sought after %pair. If unsuccessful it returns the
481    *  past-the-end ( @c end() ) iterator.
482   */
483   const_iterator
484   find(const key_type& __x) const { return _M_t.find(__x); }
485
486   /**
487    *  @brief  Finds the number of elements with given key.
488    *  @param  x  Key of (key, value) pairs to be located.
489    *  @return  Number of elements with specified key.
490    *
491    *  This function only makes sense for multimaps; for map the result will
492    *  either be 0 (not present) or 1 (present).
493   */
494   size_type
495   count(const key_type& __x) const
496     { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
497
498   /**
499    *  @brief Finds the beginning of a subsequence matching given key.
500    *  @param  x  Key of (key, value) pair to be located.
501    *  @return  Iterator pointing to first element matching given key, or
502    *           end() if not found.
503    *
504    *  This function is useful only with multimaps.  It returns the first
505    *  element of a subsequence of elements that matches the given key.  If
506    *  unsuccessful it returns an iterator pointing to the first element that
507    *  has a greater value than given key or end() if no such element exists.
508   */
509   iterator
510   lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); }
511
512   /**
513    *  @brief Finds the beginning of a subsequence matching given key.
514    *  @param  x  Key of (key, value) pair to be located.
515    *  @return  Read-only (constant) iterator pointing to first element
516    *           matching given key, or end() if not found.
517    *
518    *  This function is useful only with multimaps.  It returns the first
519    *  element of a subsequence of elements that matches the given key.  If
520    *  unsuccessful the iterator will point to the next greatest element or,
521    *  if no such greater element exists, to end().
522   */
523   const_iterator
524   lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); }
525
526   /**
527    *  @brief Finds the end of a subsequence matching given key.
528    *  @param  x  Key of (key, value) pair to be located.
529    *  @return Iterator pointing to last element matching given key.
530    *
531    *  This function only makes sense with multimaps.
532   */
533   iterator
534   upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); }
535
536   /**
537    *  @brief Finds the end of a subsequence matching given key.
538    *  @param  x  Key of (key, value) pair to be located.
539    *  @return  Read-only (constant) iterator pointing to last element matching
540    *           given key.
541    *
542    *  This function only makes sense with multimaps.
543   */
544   const_iterator
545   upper_bound(const key_type& __x) const
546     { return _M_t.upper_bound(__x); }
547
548   /**
549    *  @brief Finds a subsequence matching given key.
550    *  @param  x  Key of (key, value) pairs to be located.
551    *  @return  Pair of iterators that possibly points to the subsequence
552    *           matching given key.
553    *
554    *  This function returns a pair of which the first
555    *  element possibly points to the first element matching the given key
556    *  and the second element possibly points to the last element matching the
557    *  given key.  If unsuccessful the first element of the returned pair will
558    *  contain an iterator pointing to the next greatest element or, if no such
559    *  greater element exists, to end().
560    *
561    *  This function only makes sense for multimaps.
562   */
563   pair<iterator,iterator>
564   equal_range(const key_type& __x)
565     { return _M_t.equal_range(__x); }
566
567   /**
568    *  @brief Finds a subsequence matching given key.
569    *  @param  x  Key of (key, value) pairs to be located.
570    *  @return  Pair of read-only (constant) iterators that possibly points to
571    *           the subsequence matching given key.
572    *
573    *  This function returns a pair of which the first
574    *  element possibly points to the first element matching the given key
575    *  and the second element possibly points to the last element matching the
576    *  given key.  If unsuccessful the first element of the returned pair will
577    *  contain an iterator pointing to the next greatest element or, if no such
578    *  a greater element exists, to end().
579    *
580    *  This function only makes sense for multimaps.
581   */
582   pair<const_iterator,const_iterator>
583   equal_range(const key_type& __x) const
584     { return _M_t.equal_range(__x); }
585
586   template <typename _K1, typename _T1, typename _C1, typename _A1>
587   friend bool operator== (const map<_K1,_T1,_C1,_A1>&,
588                           const map<_K1,_T1,_C1,_A1>&);
589   template <typename _K1, typename _T1, typename _C1, typename _A1>
590   friend bool operator< (const map<_K1,_T1,_C1,_A1>&,
591                          const map<_K1,_T1,_C1,_A1>&);
592 };
593
594
595 /**
596  *  @brief  Map equality comparison.
597  *  @param  x  A %map.
598  *  @param  y  A %map of the same type as @a x.
599  *  @return  True iff the size and elements of the maps are equal.
600  *
601  *  This is an equivalence relation.  It is linear in the size of the
602  *  maps.  Maps are considered equivalent if their sizes are equal,
603  *  and if corresponding elements compare equal.
604 */
605 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
606   inline bool
607   operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
608              const map<_Key,_Tp,_Compare,_Alloc>& __y)
609   { return __x._M_t == __y._M_t; }
610
611 /**
612  *  @brief  Map ordering relation.
613  *  @param  x  A %map.
614  *  @param  y  A %map of the same type as @a x.
615  *  @return  True iff @a x is lexographically less than @a y.
616  *
617  *  This is a total ordering relation.  It is linear in the size of the
618  *  maps.  The elements must be comparable with @c <.
619  *
620  *  See std::lexographical_compare() for how the determination is made.
621 */
622 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
623   inline bool
624   operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
625             const map<_Key,_Tp,_Compare,_Alloc>& __y)
626   { return __x._M_t < __y._M_t; }
627
628 /// Based on operator==
629 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
630   inline bool
631   operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
632              const map<_Key,_Tp,_Compare,_Alloc>& __y)
633   { return !(__x == __y); }
634
635 /// Based on operator<
636 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
637   inline bool
638   operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x,
639             const map<_Key,_Tp,_Compare,_Alloc>& __y)
640   { return __y < __x; }
641
642 /// Based on operator<
643 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
644   inline bool
645   operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
646              const map<_Key,_Tp,_Compare,_Alloc>& __y)
647   { return !(__y < __x); }
648
649 /// Based on operator<
650 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
651   inline bool
652   operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x,
653              const map<_Key,_Tp,_Compare,_Alloc>& __y)
654   { return !(__x < __y); }
655
656 /// See std::map::swap().
657 template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
658   inline void
659   swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y)
660   { __x.swap(__y); }
661
662 } // namespace std
663
664 #endif /* __GLIBCPP_INTERNAL_MAP_H */
665