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