• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/arm-none-eabi/include/c++/4.6.1/bits/
1// Multimap implementation -*- C++ -*-
2
3// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4// 2011 Free Software Foundation, Inc.
5//
6// This file is part of the GNU ISO C++ Library.  This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16
17// Under Section 7 of GPL version 3, you are granted additional
18// permissions described in the GCC Runtime Library Exception, version
19// 3.1, as published by the Free Software Foundation.
20
21// You should have received a copy of the GNU General Public License and
22// a copy of the GCC Runtime Library Exception along with this program;
23// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24// <http://www.gnu.org/licenses/>.
25
26/*
27 *
28 * Copyright (c) 1994
29 * Hewlett-Packard Company
30 *
31 * Permission to use, copy, modify, distribute and sell this software
32 * and its documentation for any purpose is hereby granted without fee,
33 * provided that the above copyright notice appear in all copies and
34 * that both that copyright notice and this permission notice appear
35 * in supporting documentation.  Hewlett-Packard Company makes no
36 * representations about the suitability of this software for any
37 * purpose.  It is provided "as is" without express or implied warranty.
38 *
39 *
40 * Copyright (c) 1996,1997
41 * Silicon Graphics Computer Systems, Inc.
42 *
43 * Permission to use, copy, modify, distribute and sell this software
44 * and its documentation for any purpose is hereby granted without fee,
45 * provided that the above copyright notice appear in all copies and
46 * that both that copyright notice and this permission notice appear
47 * in supporting documentation.  Silicon Graphics makes no
48 * representations about the suitability of this software for any
49 * purpose.  It is provided "as is" without express or implied warranty.
50 */
51
52/** @file bits/stl_multimap.h
53 *  This is an internal header file, included by other library headers.
54 *  Do not attempt to use it directly. @headername{map}
55 */
56
57#ifndef _STL_MULTIMAP_H
58#define _STL_MULTIMAP_H 1
59
60#include <bits/concept_check.h>
61#include <initializer_list>
62
63namespace std _GLIBCXX_VISIBILITY(default)
64{
65_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
66
67  /**
68   *  @brief A standard container made up of (key,value) pairs, which can be
69   *  retrieved based on a key, in logarithmic time.
70   *
71   *  @ingroup associative_containers
72   *
73   *  Meets the requirements of a <a href="tables.html#65">container</a>, a
74   *  <a href="tables.html#66">reversible container</a>, and an
75   *  <a href="tables.html#69">associative container</a> (using equivalent
76   *  keys).  For a @c multimap<Key,T> the key_type is Key, the mapped_type
77   *  is T, and the value_type is std::pair<const Key,T>.
78   *
79   *  Multimaps support bidirectional iterators.
80   *
81   *  The private tree data is declared exactly the same way for map and
82   *  multimap; the distinction is made entirely in how the tree functions are
83   *  called (*_unique versus *_equal, same as the standard).
84  */
85  template <typename _Key, typename _Tp,
86	    typename _Compare = std::less<_Key>,
87	    typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
88    class multimap
89    {
90    public:
91      typedef _Key                                          key_type;
92      typedef _Tp                                           mapped_type;
93      typedef std::pair<const _Key, _Tp>                    value_type;
94      typedef _Compare                                      key_compare;
95      typedef _Alloc                                        allocator_type;
96
97    private:
98      // concept requirements
99      typedef typename _Alloc::value_type                   _Alloc_value_type;
100      __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
101      __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
102				_BinaryFunctionConcept)
103      __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
104
105    public:
106      class value_compare
107      : public std::binary_function<value_type, value_type, bool>
108      {
109	friend class multimap<_Key, _Tp, _Compare, _Alloc>;
110      protected:
111	_Compare comp;
112
113	value_compare(_Compare __c)
114	: comp(__c) { }
115
116      public:
117	bool operator()(const value_type& __x, const value_type& __y) const
118	{ return comp(__x.first, __y.first); }
119      };
120
121    private:
122      /// This turns a red-black tree into a [multi]map.
123      typedef typename _Alloc::template rebind<value_type>::other
124        _Pair_alloc_type;
125
126      typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
127		       key_compare, _Pair_alloc_type> _Rep_type;
128      /// The actual tree structure.
129      _Rep_type _M_t;
130
131    public:
132      // many of these are specified differently in ISO, but the following are
133      // "functionally equivalent"
134      typedef typename _Pair_alloc_type::pointer         pointer;
135      typedef typename _Pair_alloc_type::const_pointer   const_pointer;
136      typedef typename _Pair_alloc_type::reference       reference;
137      typedef typename _Pair_alloc_type::const_reference const_reference;
138      typedef typename _Rep_type::iterator               iterator;
139      typedef typename _Rep_type::const_iterator         const_iterator;
140      typedef typename _Rep_type::size_type              size_type;
141      typedef typename _Rep_type::difference_type        difference_type;
142      typedef typename _Rep_type::reverse_iterator       reverse_iterator;
143      typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
144
145      // [23.3.2] construct/copy/destroy
146      // (get_allocator() is also listed in this section)
147      /**
148       *  @brief  Default constructor creates no elements.
149       */
150      multimap()
151      : _M_t() { }
152
153      /**
154       *  @brief  Creates a %multimap with no elements.
155       *  @param  comp  A comparison object.
156       *  @param  a  An allocator object.
157       */
158      explicit
159      multimap(const _Compare& __comp,
160	       const allocator_type& __a = allocator_type())
161      : _M_t(__comp, __a) { }
162
163      /**
164       *  @brief  %Multimap copy constructor.
165       *  @param  x  A %multimap of identical element and allocator types.
166       *
167       *  The newly-created %multimap uses a copy of the allocation object
168       *  used by @a x.
169       */
170      multimap(const multimap& __x)
171      : _M_t(__x._M_t) { }
172
173#ifdef __GXX_EXPERIMENTAL_CXX0X__
174      /**
175       *  @brief  %Multimap move constructor.
176       *  @param   x  A %multimap of identical element and allocator types.
177       *
178       *  The newly-created %multimap contains the exact contents of @a x.
179       *  The contents of @a x are a valid, but unspecified %multimap.
180       */
181      multimap(multimap&& __x)
182      : _M_t(std::move(__x._M_t)) { }
183
184      /**
185       *  @brief  Builds a %multimap from an initializer_list.
186       *  @param  l  An initializer_list.
187       *  @param  comp  A comparison functor.
188       *  @param  a  An allocator object.
189       *
190       *  Create a %multimap consisting of copies of the elements from
191       *  the initializer_list.  This is linear in N if the list is already
192       *  sorted, and NlogN otherwise (where N is @a __l.size()).
193       */
194      multimap(initializer_list<value_type> __l,
195	       const _Compare& __comp = _Compare(),
196	       const allocator_type& __a = allocator_type())
197      : _M_t(__comp, __a)
198      { _M_t._M_insert_equal(__l.begin(), __l.end()); }
199#endif
200
201      /**
202       *  @brief  Builds a %multimap from a range.
203       *  @param  first  An input iterator.
204       *  @param  last  An input iterator.
205       *
206       *  Create a %multimap consisting of copies of the elements from
207       *  [first,last).  This is linear in N if the range is already sorted,
208       *  and NlogN otherwise (where N is distance(first,last)).
209       */
210      template<typename _InputIterator>
211        multimap(_InputIterator __first, _InputIterator __last)
212	: _M_t()
213        { _M_t._M_insert_equal(__first, __last); }
214
215      /**
216       *  @brief  Builds a %multimap from a range.
217       *  @param  first  An input iterator.
218       *  @param  last  An input iterator.
219       *  @param  comp  A comparison functor.
220       *  @param  a  An allocator object.
221       *
222       *  Create a %multimap consisting of copies of the elements from
223       *  [first,last).  This is linear in N if the range is already sorted,
224       *  and NlogN otherwise (where N is distance(first,last)).
225       */
226      template<typename _InputIterator>
227        multimap(_InputIterator __first, _InputIterator __last,
228		 const _Compare& __comp,
229		 const allocator_type& __a = allocator_type())
230        : _M_t(__comp, __a)
231        { _M_t._M_insert_equal(__first, __last); }
232
233      // FIXME There is no dtor declared, but we should have something generated
234      // by Doxygen.  I don't know what tags to add to this paragraph to make
235      // that happen:
236      /**
237       *  The dtor only erases the elements, and note that if the elements
238       *  themselves are pointers, the pointed-to memory is not touched in any
239       *  way.  Managing the pointer is the user's responsibility.
240       */
241
242      /**
243       *  @brief  %Multimap assignment operator.
244       *  @param  x  A %multimap of identical element and allocator types.
245       *
246       *  All the elements of @a x are copied, but unlike the copy constructor,
247       *  the allocator object is not copied.
248       */
249      multimap&
250      operator=(const multimap& __x)
251      {
252	_M_t = __x._M_t;
253	return *this;
254      }
255
256#ifdef __GXX_EXPERIMENTAL_CXX0X__
257      /**
258       *  @brief  %Multimap move assignment operator.
259       *  @param  x  A %multimap of identical element and allocator types.
260       *
261       *  The contents of @a x are moved into this multimap (without copying).
262       *  @a x is a valid, but unspecified multimap.
263       */
264      multimap&
265      operator=(multimap&& __x)
266      {
267	// NB: DR 1204.
268	// NB: DR 675.
269	this->clear();
270	this->swap(__x);
271	return *this;
272      }
273
274      /**
275       *  @brief  %Multimap list assignment operator.
276       *  @param  l  An initializer_list.
277       *
278       *  This function fills a %multimap with copies of the elements
279       *  in the initializer list @a l.
280       *
281       *  Note that the assignment completely changes the %multimap and
282       *  that the resulting %multimap's size is the same as the number
283       *  of elements assigned.  Old data may be lost.
284       */
285      multimap&
286      operator=(initializer_list<value_type> __l)
287      {
288	this->clear();
289	this->insert(__l.begin(), __l.end());
290	return *this;
291      }
292#endif
293
294      /// Get a copy of the memory allocation object.
295      allocator_type
296      get_allocator() const
297      { return _M_t.get_allocator(); }
298
299      // iterators
300      /**
301       *  Returns a read/write iterator that points to the first pair in the
302       *  %multimap.  Iteration is done in ascending order according to the
303       *  keys.
304       */
305      iterator
306      begin()
307      { return _M_t.begin(); }
308
309      /**
310       *  Returns a read-only (constant) iterator that points to the first pair
311       *  in the %multimap.  Iteration is done in ascending order according to
312       *  the keys.
313       */
314      const_iterator
315      begin() const
316      { return _M_t.begin(); }
317
318      /**
319       *  Returns a read/write iterator that points one past the last pair in
320       *  the %multimap.  Iteration is done in ascending order according to the
321       *  keys.
322       */
323      iterator
324      end()
325      { return _M_t.end(); }
326
327      /**
328       *  Returns a read-only (constant) iterator that points one past the last
329       *  pair in the %multimap.  Iteration is done in ascending order according
330       *  to the keys.
331       */
332      const_iterator
333      end() const
334      { return _M_t.end(); }
335
336      /**
337       *  Returns a read/write reverse iterator that points to the last pair in
338       *  the %multimap.  Iteration is done in descending order according to the
339       *  keys.
340       */
341      reverse_iterator
342      rbegin()
343      { return _M_t.rbegin(); }
344
345      /**
346       *  Returns a read-only (constant) reverse iterator that points to the
347       *  last pair in the %multimap.  Iteration is done in descending order
348       *  according to the keys.
349       */
350      const_reverse_iterator
351      rbegin() const
352      { return _M_t.rbegin(); }
353
354      /**
355       *  Returns a read/write reverse iterator that points to one before the
356       *  first pair in the %multimap.  Iteration is done in descending order
357       *  according to the keys.
358       */
359      reverse_iterator
360      rend()
361      { return _M_t.rend(); }
362
363      /**
364       *  Returns a read-only (constant) reverse iterator that points to one
365       *  before the first pair in the %multimap.  Iteration is done in
366       *  descending order according to the keys.
367       */
368      const_reverse_iterator
369      rend() const
370      { return _M_t.rend(); }
371
372#ifdef __GXX_EXPERIMENTAL_CXX0X__
373      /**
374       *  Returns a read-only (constant) iterator that points to the first pair
375       *  in the %multimap.  Iteration is done in ascending order according to
376       *  the keys.
377       */
378      const_iterator
379      cbegin() const
380      { return _M_t.begin(); }
381
382      /**
383       *  Returns a read-only (constant) iterator that points one past the last
384       *  pair in the %multimap.  Iteration is done in ascending order according
385       *  to the keys.
386       */
387      const_iterator
388      cend() const
389      { return _M_t.end(); }
390
391      /**
392       *  Returns a read-only (constant) reverse iterator that points to the
393       *  last pair in the %multimap.  Iteration is done in descending order
394       *  according to the keys.
395       */
396      const_reverse_iterator
397      crbegin() const
398      { return _M_t.rbegin(); }
399
400      /**
401       *  Returns a read-only (constant) reverse iterator that points to one
402       *  before the first pair in the %multimap.  Iteration is done in
403       *  descending order according to the keys.
404       */
405      const_reverse_iterator
406      crend() const
407      { return _M_t.rend(); }
408#endif
409
410      // capacity
411      /** Returns true if the %multimap is empty.  */
412      bool
413      empty() const
414      { return _M_t.empty(); }
415
416      /** Returns the size of the %multimap.  */
417      size_type
418      size() const
419      { return _M_t.size(); }
420
421      /** Returns the maximum size of the %multimap.  */
422      size_type
423      max_size() const
424      { return _M_t.max_size(); }
425
426      // modifiers
427      /**
428       *  @brief Inserts a std::pair into the %multimap.
429       *  @param  x  Pair to be inserted (see std::make_pair for easy creation
430       *             of pairs).
431       *  @return An iterator that points to the inserted (key,value) pair.
432       *
433       *  This function inserts a (key, value) pair into the %multimap.
434       *  Contrary to a std::map the %multimap does not rely on unique keys and
435       *  thus multiple pairs with the same key can be inserted.
436       *
437       *  Insertion requires logarithmic time.
438       */
439      iterator
440      insert(const value_type& __x)
441      { return _M_t._M_insert_equal(__x); }
442
443#ifdef __GXX_EXPERIMENTAL_CXX0X__
444      template<typename _Pair, typename = typename
445	       std::enable_if<std::is_convertible<_Pair,
446						  value_type>::value>::type>
447        iterator
448        insert(_Pair&& __x)
449        { return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
450#endif
451
452      /**
453       *  @brief Inserts a std::pair into the %multimap.
454       *  @param  position  An iterator that serves as a hint as to where the
455       *                    pair should be inserted.
456       *  @param  x  Pair to be inserted (see std::make_pair for easy creation
457       *             of pairs).
458       *  @return An iterator that points to the inserted (key,value) pair.
459       *
460       *  This function inserts a (key, value) pair into the %multimap.
461       *  Contrary to a std::map the %multimap does not rely on unique keys and
462       *  thus multiple pairs with the same key can be inserted.
463       *  Note that the first parameter is only a hint and can potentially
464       *  improve the performance of the insertion process.  A bad hint would
465       *  cause no gains in efficiency.
466       *
467       *  For more on @a hinting, see:
468       *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
469       *
470       *  Insertion requires logarithmic time (if the hint is not taken).
471       */
472      iterator
473#ifdef __GXX_EXPERIMENTAL_CXX0X__
474      insert(const_iterator __position, const value_type& __x)
475#else
476      insert(iterator __position, const value_type& __x)
477#endif
478      { return _M_t._M_insert_equal_(__position, __x); }
479
480#ifdef __GXX_EXPERIMENTAL_CXX0X__
481      template<typename _Pair, typename = typename
482	       std::enable_if<std::is_convertible<_Pair,
483						  value_type>::value>::type>
484        iterator
485        insert(const_iterator __position, _Pair&& __x)
486        { return _M_t._M_insert_equal_(__position,
487				       std::forward<_Pair>(__x)); }
488#endif
489
490      /**
491       *  @brief A template function that attempts to insert a range
492       *  of elements.
493       *  @param  first  Iterator pointing to the start of the range to be
494       *                 inserted.
495       *  @param  last  Iterator pointing to the end of the range.
496       *
497       *  Complexity similar to that of the range constructor.
498       */
499      template<typename _InputIterator>
500        void
501        insert(_InputIterator __first, _InputIterator __last)
502        { _M_t._M_insert_equal(__first, __last); }
503
504#ifdef __GXX_EXPERIMENTAL_CXX0X__
505      /**
506       *  @brief Attempts to insert a list of std::pairs into the %multimap.
507       *  @param  list  A std::initializer_list<value_type> of pairs to be
508       *                inserted.
509       *
510       *  Complexity similar to that of the range constructor.
511       */
512      void
513      insert(initializer_list<value_type> __l)
514      { this->insert(__l.begin(), __l.end()); }
515#endif
516
517#ifdef __GXX_EXPERIMENTAL_CXX0X__
518      // _GLIBCXX_RESOLVE_LIB_DEFECTS
519      // DR 130. Associative erase should return an iterator.
520      /**
521       *  @brief Erases an element from a %multimap.
522       *  @param  position  An iterator pointing to the element to be erased.
523       *  @return An iterator pointing to the element immediately following
524       *          @a position prior to the element being erased. If no such
525       *          element exists, end() is returned.
526       *
527       *  This function erases an element, pointed to by the given iterator,
528       *  from a %multimap.  Note that this function only erases the element,
529       *  and that if the element is itself a pointer, the pointed-to memory is
530       *  not touched in any way.  Managing the pointer is the user's
531       *  responsibility.
532       */
533      iterator
534      erase(const_iterator __position)
535      { return _M_t.erase(__position); }
536#else
537      /**
538       *  @brief Erases an element from a %multimap.
539       *  @param  position  An iterator pointing to the element to be erased.
540       *
541       *  This function erases an element, pointed to by the given iterator,
542       *  from a %multimap.  Note that this function only erases the element,
543       *  and that if the element is itself a pointer, the pointed-to memory is
544       *  not touched in any way.  Managing the pointer is the user's
545       *  responsibility.
546       */
547      void
548      erase(iterator __position)
549      { _M_t.erase(__position); }
550#endif
551
552      /**
553       *  @brief Erases elements according to the provided key.
554       *  @param  x  Key of element to be erased.
555       *  @return  The number of elements erased.
556       *
557       *  This function erases all elements located by the given key from a
558       *  %multimap.
559       *  Note that this function only erases the element, and that if
560       *  the element is itself a pointer, the pointed-to memory is not touched
561       *  in any way.  Managing the pointer is the user's responsibility.
562       */
563      size_type
564      erase(const key_type& __x)
565      { return _M_t.erase(__x); }
566
567#ifdef __GXX_EXPERIMENTAL_CXX0X__
568      // _GLIBCXX_RESOLVE_LIB_DEFECTS
569      // DR 130. Associative erase should return an iterator.
570      /**
571       *  @brief Erases a [first,last) range of elements from a %multimap.
572       *  @param  first  Iterator pointing to the start of the range to be
573       *                 erased.
574       *  @param  last  Iterator pointing to the end of the range to be erased.
575       *  @return The iterator @a last.
576       *
577       *  This function erases a sequence of elements from a %multimap.
578       *  Note that this function only erases the elements, and that if
579       *  the elements themselves are pointers, the pointed-to memory is not
580       *  touched in any way.  Managing the pointer is the user's
581       *  responsibility.
582       */
583      iterator
584      erase(const_iterator __first, const_iterator __last)
585      { return _M_t.erase(__first, __last); }
586#else
587      // _GLIBCXX_RESOLVE_LIB_DEFECTS
588      // DR 130. Associative erase should return an iterator.
589      /**
590       *  @brief Erases a [first,last) range of elements from a %multimap.
591       *  @param  first  Iterator pointing to the start of the range to be
592       *                 erased.
593       *  @param  last  Iterator pointing to the end of the range to be erased.
594       *
595       *  This function erases a sequence of elements from a %multimap.
596       *  Note that this function only erases the elements, and that if
597       *  the elements themselves are pointers, the pointed-to memory is not
598       *  touched in any way.  Managing the pointer is the user's
599       *  responsibility.
600       */
601      void
602      erase(iterator __first, iterator __last)
603      { _M_t.erase(__first, __last); }
604#endif
605
606      /**
607       *  @brief  Swaps data with another %multimap.
608       *  @param  x  A %multimap of the same element and allocator types.
609       *
610       *  This exchanges the elements between two multimaps in constant time.
611       *  (It is only swapping a pointer, an integer, and an instance of
612       *  the @c Compare type (which itself is often stateless and empty), so it
613       *  should be quite fast.)
614       *  Note that the global std::swap() function is specialized such that
615       *  std::swap(m1,m2) will feed to this function.
616       */
617      void
618      swap(multimap& __x)
619      { _M_t.swap(__x._M_t); }
620
621      /**
622       *  Erases all elements in a %multimap.  Note that this function only
623       *  erases the elements, and that if the elements themselves are pointers,
624       *  the pointed-to memory is not touched in any way.  Managing the pointer
625       *  is the user's responsibility.
626       */
627      void
628      clear()
629      { _M_t.clear(); }
630
631      // observers
632      /**
633       *  Returns the key comparison object out of which the %multimap
634       *  was constructed.
635       */
636      key_compare
637      key_comp() const
638      { return _M_t.key_comp(); }
639
640      /**
641       *  Returns a value comparison object, built from the key comparison
642       *  object out of which the %multimap was constructed.
643       */
644      value_compare
645      value_comp() const
646      { return value_compare(_M_t.key_comp()); }
647
648      // multimap operations
649      /**
650       *  @brief Tries to locate an element in a %multimap.
651       *  @param  x  Key of (key, value) pair to be located.
652       *  @return  Iterator pointing to sought-after element,
653       *           or end() if not found.
654       *
655       *  This function takes a key and tries to locate the element with which
656       *  the key matches.  If successful the function returns an iterator
657       *  pointing to the sought after %pair.  If unsuccessful it returns the
658       *  past-the-end ( @c end() ) iterator.
659       */
660      iterator
661      find(const key_type& __x)
662      { return _M_t.find(__x); }
663
664      /**
665       *  @brief Tries to locate an element in a %multimap.
666       *  @param  x  Key of (key, value) pair to be located.
667       *  @return  Read-only (constant) iterator pointing to sought-after
668       *           element, or end() if not found.
669       *
670       *  This function takes a key and tries to locate the element with which
671       *  the key matches.  If successful the function returns a constant
672       *  iterator pointing to the sought after %pair.  If unsuccessful it
673       *  returns the past-the-end ( @c end() ) iterator.
674       */
675      const_iterator
676      find(const key_type& __x) const
677      { return _M_t.find(__x); }
678
679      /**
680       *  @brief Finds the number of elements with given key.
681       *  @param  x  Key of (key, value) pairs to be located.
682       *  @return Number of elements with specified key.
683       */
684      size_type
685      count(const key_type& __x) const
686      { return _M_t.count(__x); }
687
688      /**
689       *  @brief Finds the beginning of a subsequence matching given key.
690       *  @param  x  Key of (key, value) pair to be located.
691       *  @return  Iterator pointing to first element equal to or greater
692       *           than key, or end().
693       *
694       *  This function returns the first element of a subsequence of elements
695       *  that matches the given key.  If unsuccessful it returns an iterator
696       *  pointing to the first element that has a greater value than given key
697       *  or end() if no such element exists.
698       */
699      iterator
700      lower_bound(const key_type& __x)
701      { return _M_t.lower_bound(__x); }
702
703      /**
704       *  @brief Finds the beginning of a subsequence matching given key.
705       *  @param  x  Key of (key, value) pair to be located.
706       *  @return  Read-only (constant) iterator pointing to first element
707       *           equal to or greater than key, or end().
708       *
709       *  This function returns the first element of a subsequence of elements
710       *  that matches the given key.  If unsuccessful the iterator will point
711       *  to the next greatest element or, if no such greater element exists, to
712       *  end().
713       */
714      const_iterator
715      lower_bound(const key_type& __x) const
716      { return _M_t.lower_bound(__x); }
717
718      /**
719       *  @brief Finds the end of a subsequence matching given key.
720       *  @param  x  Key of (key, value) pair to be located.
721       *  @return Iterator pointing to the first element
722       *          greater than key, or end().
723       */
724      iterator
725      upper_bound(const key_type& __x)
726      { return _M_t.upper_bound(__x); }
727
728      /**
729       *  @brief Finds the end of a subsequence matching given key.
730       *  @param  x  Key of (key, value) pair to be located.
731       *  @return  Read-only (constant) iterator pointing to first iterator
732       *           greater than key, or end().
733       */
734      const_iterator
735      upper_bound(const key_type& __x) const
736      { return _M_t.upper_bound(__x); }
737
738      /**
739       *  @brief Finds a subsequence matching given key.
740       *  @param  x  Key of (key, value) pairs to be located.
741       *  @return  Pair of iterators that possibly points to the subsequence
742       *           matching given key.
743       *
744       *  This function is equivalent to
745       *  @code
746       *    std::make_pair(c.lower_bound(val),
747       *                   c.upper_bound(val))
748       *  @endcode
749       *  (but is faster than making the calls separately).
750       */
751      std::pair<iterator, iterator>
752      equal_range(const key_type& __x)
753      { return _M_t.equal_range(__x); }
754
755      /**
756       *  @brief Finds a subsequence matching given key.
757       *  @param  x  Key of (key, value) pairs to be located.
758       *  @return  Pair of read-only (constant) iterators that possibly points
759       *           to the subsequence matching given key.
760       *
761       *  This function is equivalent to
762       *  @code
763       *    std::make_pair(c.lower_bound(val),
764       *                   c.upper_bound(val))
765       *  @endcode
766       *  (but is faster than making the calls separately).
767       */
768      std::pair<const_iterator, const_iterator>
769      equal_range(const key_type& __x) const
770      { return _M_t.equal_range(__x); }
771
772      template<typename _K1, typename _T1, typename _C1, typename _A1>
773        friend bool
774        operator==(const multimap<_K1, _T1, _C1, _A1>&,
775		   const multimap<_K1, _T1, _C1, _A1>&);
776
777      template<typename _K1, typename _T1, typename _C1, typename _A1>
778        friend bool
779        operator<(const multimap<_K1, _T1, _C1, _A1>&,
780		  const multimap<_K1, _T1, _C1, _A1>&);
781  };
782
783  /**
784   *  @brief  Multimap equality comparison.
785   *  @param  x  A %multimap.
786   *  @param  y  A %multimap of the same type as @a x.
787   *  @return  True iff the size and elements of the maps are equal.
788   *
789   *  This is an equivalence relation.  It is linear in the size of the
790   *  multimaps.  Multimaps are considered equivalent if their sizes are equal,
791   *  and if corresponding elements compare equal.
792  */
793  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
794    inline bool
795    operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
796               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
797    { return __x._M_t == __y._M_t; }
798
799  /**
800   *  @brief  Multimap ordering relation.
801   *  @param  x  A %multimap.
802   *  @param  y  A %multimap of the same type as @a x.
803   *  @return  True iff @a x is lexicographically less than @a y.
804   *
805   *  This is a total ordering relation.  It is linear in the size of the
806   *  multimaps.  The elements must be comparable with @c <.
807   *
808   *  See std::lexicographical_compare() for how the determination is made.
809  */
810  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
811    inline bool
812    operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
813              const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
814    { return __x._M_t < __y._M_t; }
815
816  /// Based on operator==
817  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
818    inline bool
819    operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
820               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
821    { return !(__x == __y); }
822
823  /// Based on operator<
824  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
825    inline bool
826    operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
827              const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
828    { return __y < __x; }
829
830  /// Based on operator<
831  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
832    inline bool
833    operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
834               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
835    { return !(__y < __x); }
836
837  /// Based on operator<
838  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
839    inline bool
840    operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
841               const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
842    { return !(__x < __y); }
843
844  /// See std::multimap::swap().
845  template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
846    inline void
847    swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
848         multimap<_Key, _Tp, _Compare, _Alloc>& __y)
849    { __x.swap(__y); }
850
851_GLIBCXX_END_NAMESPACE_CONTAINER
852} // namespace std
853
854#endif /* _STL_MULTIMAP_H */
855