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