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