Brian Silverman | fad8f55 | 2018-08-04 23:36:19 -0700 | [diff] [blame^] | 1 | ////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // See http://www.boost.org/libs/container for documentation. |
| 8 | // |
| 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | #ifndef BOOST_CONTAINER_MAP_HPP |
| 11 | #define BOOST_CONTAINER_MAP_HPP |
| 12 | |
| 13 | #ifndef BOOST_CONFIG_HPP |
| 14 | # include <boost/config.hpp> |
| 15 | #endif |
| 16 | |
| 17 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 18 | # pragma once |
| 19 | #endif |
| 20 | |
| 21 | #include <boost/container/detail/config_begin.hpp> |
| 22 | #include <boost/container/detail/workaround.hpp> |
| 23 | |
| 24 | // container |
| 25 | #include <boost/container/container_fwd.hpp> |
| 26 | #include <boost/container/new_allocator.hpp> //new_allocator |
| 27 | #include <boost/container/throw_exception.hpp> |
| 28 | // container/detail |
| 29 | #include <boost/container/detail/mpl.hpp> |
| 30 | #include <boost/container/detail/tree.hpp> |
| 31 | #include <boost/container/detail/type_traits.hpp> |
| 32 | #include <boost/container/detail/value_init.hpp> |
| 33 | #include <boost/container/detail/pair.hpp> |
| 34 | #include <boost/container/detail/pair_key_mapped_of_value.hpp> |
| 35 | |
| 36 | // move |
| 37 | #include <boost/move/traits.hpp> |
| 38 | #include <boost/move/utility_core.hpp> |
| 39 | // move/detail |
| 40 | #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 41 | #include <boost/move/detail/fwd_macros.hpp> |
| 42 | #endif |
| 43 | #include <boost/move/detail/move_helpers.hpp> |
| 44 | // intrusive/detail |
| 45 | #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair |
| 46 | #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal |
| 47 | // other |
| 48 | #include <boost/static_assert.hpp> |
| 49 | #include <boost/core/no_exceptions_support.hpp> |
| 50 | // std |
| 51 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 52 | #include <initializer_list> |
| 53 | #endif |
| 54 | |
| 55 | namespace boost { |
| 56 | namespace container { |
| 57 | |
| 58 | #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 59 | |
| 60 | //! A map is a kind of associative container that supports unique keys (contains at |
| 61 | //! most one of each key value) and provides for fast retrieval of values of another |
| 62 | //! type T based on the keys. The map class supports bidirectional iterators. |
| 63 | //! |
| 64 | //! A map satisfies all of the requirements of a container and of a reversible |
| 65 | //! container and of an associative container. The <code>value_type</code> stored |
| 66 | //! by this container is the value_type is std::pair<const Key, T>. |
| 67 | //! |
| 68 | //! \tparam Key is the key_type of the map |
| 69 | //! \tparam T is the <code>mapped_type</code> |
| 70 | //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>). |
| 71 | //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s |
| 72 | //! (e.g. <i>allocator< std::pair<const Key, T> > </i>). |
| 73 | //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options. |
| 74 | template < class Key, class T, class Compare = std::less<Key> |
| 75 | , class Allocator = new_allocator< std::pair< const Key, T> >, class Options = tree_assoc_defaults > |
| 76 | #else |
| 77 | template <class Key, class T, class Compare, class Allocator, class Options> |
| 78 | #endif |
| 79 | class map |
| 80 | ///@cond |
| 81 | : public dtl::tree |
| 82 | < std::pair<const Key, T> |
| 83 | , dtl::select1st<Key> |
| 84 | , Compare, Allocator, Options> |
| 85 | ///@endcond |
| 86 | { |
| 87 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 88 | private: |
| 89 | BOOST_COPYABLE_AND_MOVABLE(map) |
| 90 | |
| 91 | typedef dtl::select1st<Key> select_1st_t; |
| 92 | typedef std::pair<const Key, T> value_type_impl; |
| 93 | typedef dtl::tree |
| 94 | <value_type_impl, select_1st_t, Compare, Allocator, Options> base_t; |
| 95 | typedef dtl::pair <Key, T> movable_value_type_impl; |
| 96 | typedef typename base_t::value_compare value_compare_impl; |
| 97 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 98 | |
| 99 | public: |
| 100 | ////////////////////////////////////////////// |
| 101 | // |
| 102 | // types |
| 103 | // |
| 104 | ////////////////////////////////////////////// |
| 105 | |
| 106 | typedef Key key_type; |
| 107 | typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type; |
| 108 | typedef T mapped_type; |
| 109 | typedef typename boost::container::allocator_traits<Allocator>::value_type value_type; |
| 110 | typedef typename boost::container::allocator_traits<Allocator>::pointer pointer; |
| 111 | typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer; |
| 112 | typedef typename boost::container::allocator_traits<Allocator>::reference reference; |
| 113 | typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference; |
| 114 | typedef typename boost::container::allocator_traits<Allocator>::size_type size_type; |
| 115 | typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type; |
| 116 | typedef Allocator allocator_type; |
| 117 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; |
| 118 | typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; |
| 119 | typedef Compare key_compare; |
| 120 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; |
| 121 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; |
| 122 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; |
| 123 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; |
| 124 | typedef std::pair<key_type, mapped_type> nonconst_value_type; |
| 125 | typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; |
| 126 | typedef BOOST_CONTAINER_IMPDEF(node_handle< |
| 127 | typename base_t::stored_allocator_type |
| 128 | BOOST_MOVE_I pair_key_mapped_of_value |
| 129 | <key_type BOOST_MOVE_I mapped_type> >) node_type; |
| 130 | typedef BOOST_CONTAINER_IMPDEF |
| 131 | (insert_return_type_base<iterator BOOST_MOVE_I node_type>) insert_return_type; |
| 132 | |
| 133 | //allocator_type::value_type type must be std::pair<CONST Key, T> |
| 134 | BOOST_STATIC_ASSERT((dtl::is_same<typename allocator_type::value_type, std::pair<const Key, T> >::value)); |
| 135 | |
| 136 | ////////////////////////////////////////////// |
| 137 | // |
| 138 | // construct/copy/destroy |
| 139 | // |
| 140 | ////////////////////////////////////////////// |
| 141 | |
| 142 | //! <b>Effects</b>: Default constructs an empty map. |
| 143 | //! |
| 144 | //! <b>Complexity</b>: Constant. |
| 145 | BOOST_CONTAINER_FORCEINLINE |
| 146 | map() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value && |
| 147 | dtl::is_nothrow_default_constructible<Compare>::value) |
| 148 | : base_t() |
| 149 | {} |
| 150 | |
| 151 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object |
| 152 | //! and allocator. |
| 153 | //! |
| 154 | //! <b>Complexity</b>: Constant. |
| 155 | BOOST_CONTAINER_FORCEINLINE map(const Compare& comp, const allocator_type& a) |
| 156 | : base_t(comp, a) |
| 157 | {} |
| 158 | |
| 159 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object. |
| 160 | //! |
| 161 | //! <b>Complexity</b>: Constant. |
| 162 | BOOST_CONTAINER_FORCEINLINE explicit map(const Compare& comp) |
| 163 | : base_t(comp) |
| 164 | {} |
| 165 | |
| 166 | //! <b>Effects</b>: Constructs an empty map using the specified allocator. |
| 167 | //! |
| 168 | //! <b>Complexity</b>: Constant. |
| 169 | BOOST_CONTAINER_FORCEINLINE explicit map(const allocator_type& a) |
| 170 | : base_t(a) |
| 171 | {} |
| 172 | |
| 173 | //! <b>Effects</b>: Constructs an empty map and |
| 174 | //! inserts elements from the range [first ,last ). |
| 175 | //! |
| 176 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 177 | //! the predicate and otherwise N logN, where N is last - first. |
| 178 | template <class InputIterator> |
| 179 | BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last) |
| 180 | : base_t(true, first, last) |
| 181 | {} |
| 182 | |
| 183 | //! <b>Effects</b>: Constructs an empty map using the specified |
| 184 | //! allocator, and inserts elements from the range [first ,last ). |
| 185 | //! |
| 186 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 187 | //! the predicate and otherwise N logN, where N is last - first. |
| 188 | template <class InputIterator> |
| 189 | BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const allocator_type& a) |
| 190 | : base_t(true, first, last, Compare(), a) |
| 191 | {} |
| 192 | |
| 193 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 194 | //! inserts elements from the range [first ,last ). |
| 195 | //! |
| 196 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 197 | //! the predicate and otherwise N logN, where N is last - first. |
| 198 | template <class InputIterator> |
| 199 | BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const Compare& comp) |
| 200 | : base_t(true, first, last, comp) |
| 201 | {} |
| 202 | |
| 203 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 204 | //! allocator, and inserts elements from the range [first ,last ). |
| 205 | //! |
| 206 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 207 | //! the predicate and otherwise N logN, where N is last - first. |
| 208 | template <class InputIterator> |
| 209 | BOOST_CONTAINER_FORCEINLINE map(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a) |
| 210 | : base_t(true, first, last, comp, a) |
| 211 | {} |
| 212 | |
| 213 | //! <b>Effects</b>: Constructs an empty map and |
| 214 | //! inserts elements from the ordered unique range [first ,last). This function |
| 215 | //! is more efficient than the normal range creation for ordered ranges. |
| 216 | //! |
| 217 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 218 | //! unique values. |
| 219 | //! |
| 220 | //! <b>Complexity</b>: Linear in N. |
| 221 | //! |
| 222 | //! <b>Note</b>: Non-standard extension. |
| 223 | template <class InputIterator> |
| 224 | BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last) |
| 225 | : base_t(ordered_range, first, last) |
| 226 | {} |
| 227 | |
| 228 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 229 | //! inserts elements from the ordered unique range [first ,last). This function |
| 230 | //! is more efficient than the normal range creation for ordered ranges. |
| 231 | //! |
| 232 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 233 | //! unique values. |
| 234 | //! |
| 235 | //! <b>Complexity</b>: Linear in N. |
| 236 | //! |
| 237 | //! <b>Note</b>: Non-standard extension. |
| 238 | template <class InputIterator> |
| 239 | BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp) |
| 240 | : base_t(ordered_range, first, last, comp) |
| 241 | {} |
| 242 | |
| 243 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 244 | //! allocator, and inserts elements from the ordered unique range [first ,last). This function |
| 245 | //! is more efficient than the normal range creation for ordered ranges. |
| 246 | //! |
| 247 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be |
| 248 | //! unique values. |
| 249 | //! |
| 250 | //! <b>Complexity</b>: Linear in N. |
| 251 | //! |
| 252 | //! <b>Note</b>: Non-standard extension. |
| 253 | template <class InputIterator> |
| 254 | BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, InputIterator first, InputIterator last |
| 255 | , const Compare& comp, const allocator_type& a) |
| 256 | : base_t(ordered_range, first, last, comp, a) |
| 257 | {} |
| 258 | |
| 259 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 260 | //! <b>Effects</b>: Constructs an empty map and |
| 261 | //! inserts elements from the range [il.begin(), il.end()). |
| 262 | //! |
| 263 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted according |
| 264 | //! to the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 265 | BOOST_CONTAINER_FORCEINLINE map(std::initializer_list<value_type> il) |
| 266 | : base_t(true, il.begin(), il.end()) |
| 267 | {} |
| 268 | |
| 269 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 270 | //! inserts elements from the range [il.begin(), il.end()). |
| 271 | //! |
| 272 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 273 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 274 | BOOST_CONTAINER_FORCEINLINE map(std::initializer_list<value_type> il, const Compare& comp) |
| 275 | : base_t(true, il.begin(), il.end(), comp) |
| 276 | {} |
| 277 | |
| 278 | //! <b>Effects</b>: Constructs an empty map using the specified |
| 279 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 280 | //! |
| 281 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 282 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 283 | BOOST_CONTAINER_FORCEINLINE map(std::initializer_list<value_type> il, const allocator_type& a) |
| 284 | : base_t(true, il.begin(), il.end(), Compare(), a) |
| 285 | {} |
| 286 | |
| 287 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 288 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 289 | //! |
| 290 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 291 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 292 | BOOST_CONTAINER_FORCEINLINE map(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 293 | : base_t(true, il.begin(), il.end(), comp, a) |
| 294 | {} |
| 295 | |
| 296 | //! <b>Effects</b>: Constructs an empty map and inserts elements from the ordered unique range [il.begin(), il.end()). |
| 297 | //! This function is more efficient than the normal range creation for ordered ranges. |
| 298 | //! |
| 299 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 300 | //! unique values. |
| 301 | //! |
| 302 | //! <b>Complexity</b>: Linear in N. |
| 303 | //! |
| 304 | //! <b>Note</b>: Non-standard extension. |
| 305 | BOOST_CONTAINER_FORCEINLINE map(ordered_unique_range_t, std::initializer_list<value_type> il) |
| 306 | : base_t(ordered_range, il.begin(), il.end()) |
| 307 | {} |
| 308 | |
| 309 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object, |
| 310 | //! and inserts elements from the ordered unique range [il.begin(), il.end()). This function |
| 311 | //! is more efficient than the normal range creation for ordered ranges. |
| 312 | //! |
| 313 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 314 | //! unique values. |
| 315 | //! |
| 316 | //! <b>Complexity</b>: Linear in N. |
| 317 | //! |
| 318 | //! <b>Note</b>: Non-standard extension. |
| 319 | BOOST_CONTAINER_FORCEINLINE map(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp) |
| 320 | : base_t(ordered_range, il.begin(), il.end(), comp) |
| 321 | {} |
| 322 | |
| 323 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 324 | //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function |
| 325 | //! is more efficient than the normal range creation for ordered ranges. |
| 326 | //! |
| 327 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be |
| 328 | //! unique values. |
| 329 | //! |
| 330 | //! <b>Complexity</b>: Linear in N. |
| 331 | //! |
| 332 | //! <b>Note</b>: Non-standard extension. |
| 333 | BOOST_CONTAINER_FORCEINLINE map( ordered_unique_range_t, std::initializer_list<value_type> il |
| 334 | , const Compare& comp, const allocator_type& a) |
| 335 | : base_t(ordered_range, il.begin(), il.end(), comp, a) |
| 336 | {} |
| 337 | |
| 338 | #endif |
| 339 | |
| 340 | //! <b>Effects</b>: Copy constructs a map. |
| 341 | //! |
| 342 | //! <b>Complexity</b>: Linear in x.size(). |
| 343 | BOOST_CONTAINER_FORCEINLINE map(const map& x) |
| 344 | : base_t(static_cast<const base_t&>(x)) |
| 345 | {} |
| 346 | |
| 347 | //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources. |
| 348 | //! |
| 349 | //! <b>Complexity</b>: Constant. |
| 350 | //! |
| 351 | //! <b>Postcondition</b>: x is emptied. |
| 352 | BOOST_CONTAINER_FORCEINLINE map(BOOST_RV_REF(map) x) |
| 353 | BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value) |
| 354 | : base_t(BOOST_MOVE_BASE(base_t, x)) |
| 355 | {} |
| 356 | |
| 357 | //! <b>Effects</b>: Copy constructs a map using the specified allocator. |
| 358 | //! |
| 359 | //! <b>Complexity</b>: Linear in x.size(). |
| 360 | BOOST_CONTAINER_FORCEINLINE map(const map& x, const allocator_type &a) |
| 361 | : base_t(static_cast<const base_t&>(x), a) |
| 362 | {} |
| 363 | |
| 364 | //! <b>Effects</b>: Move constructs a map using the specified allocator. |
| 365 | //! Constructs *this using x's resources. |
| 366 | //! |
| 367 | //! <b>Complexity</b>: Constant if x == x.get_allocator(), linear otherwise. |
| 368 | //! |
| 369 | //! <b>Postcondition</b>: x is emptied. |
| 370 | BOOST_CONTAINER_FORCEINLINE map(BOOST_RV_REF(map) x, const allocator_type &a) |
| 371 | : base_t(BOOST_MOVE_BASE(base_t, x), a) |
| 372 | {} |
| 373 | |
| 374 | //! <b>Effects</b>: Makes *this a copy of x. |
| 375 | //! |
| 376 | //! <b>Complexity</b>: Linear in x.size(). |
| 377 | BOOST_CONTAINER_FORCEINLINE map& operator=(BOOST_COPY_ASSIGN_REF(map) x) |
| 378 | { return static_cast<map&>(this->base_t::operator=(static_cast<const base_t&>(x))); } |
| 379 | |
| 380 | //! <b>Effects</b>: this->swap(x.get()). |
| 381 | //! |
| 382 | //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment |
| 383 | //! is false and (allocation throws or value_type's move constructor throws) |
| 384 | //! |
| 385 | //! <b>Complexity</b>: Constant if allocator_traits_type:: |
| 386 | //! propagate_on_container_move_assignment is true or |
| 387 | //! this->get>allocator() == x.get_allocator(). Linear otherwise. |
| 388 | BOOST_CONTAINER_FORCEINLINE map& operator=(BOOST_RV_REF(map) x) |
| 389 | BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || |
| 390 | allocator_traits_type::is_always_equal::value) && |
| 391 | boost::container::dtl::is_nothrow_move_assignable<Compare>::value) |
| 392 | { return static_cast<map&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } |
| 393 | |
| 394 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 395 | //! <b>Effects</b>: Assign content of il to *this. |
| 396 | //! |
| 397 | BOOST_CONTAINER_FORCEINLINE map& operator=(std::initializer_list<value_type> il) |
| 398 | { |
| 399 | this->clear(); |
| 400 | insert(il.begin(), il.end()); |
| 401 | return *this; |
| 402 | } |
| 403 | #endif |
| 404 | |
| 405 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 406 | |
| 407 | //! <b>Effects</b>: Returns a copy of the allocator that |
| 408 | //! was passed to the object's constructor. |
| 409 | //! |
| 410 | //! <b>Complexity</b>: Constant. |
| 411 | allocator_type get_allocator() const; |
| 412 | |
| 413 | //! <b>Effects</b>: Returns a reference to the internal allocator. |
| 414 | //! |
| 415 | //! <b>Throws</b>: Nothing |
| 416 | //! |
| 417 | //! <b>Complexity</b>: Constant. |
| 418 | //! |
| 419 | //! <b>Note</b>: Non-standard extension. |
| 420 | stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW; |
| 421 | |
| 422 | //! <b>Effects</b>: Returns a reference to the internal allocator. |
| 423 | //! |
| 424 | //! <b>Throws</b>: Nothing |
| 425 | //! |
| 426 | //! <b>Complexity</b>: Constant. |
| 427 | //! |
| 428 | //! <b>Note</b>: Non-standard extension. |
| 429 | const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 430 | |
| 431 | //! <b>Effects</b>: Returns an iterator to the first element contained in the container. |
| 432 | //! |
| 433 | //! <b>Throws</b>: Nothing. |
| 434 | //! |
| 435 | //! <b>Complexity</b>: Constant. |
| 436 | iterator begin() BOOST_NOEXCEPT_OR_NOTHROW; |
| 437 | |
| 438 | //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container. |
| 439 | //! |
| 440 | //! <b>Throws</b>: Nothing. |
| 441 | //! |
| 442 | //! <b>Complexity</b>: Constant. |
| 443 | const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 444 | |
| 445 | //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container. |
| 446 | //! |
| 447 | //! <b>Throws</b>: Nothing. |
| 448 | //! |
| 449 | //! <b>Complexity</b>: Constant. |
| 450 | const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 451 | |
| 452 | //! <b>Effects</b>: Returns an iterator to the end of the container. |
| 453 | //! |
| 454 | //! <b>Throws</b>: Nothing. |
| 455 | //! |
| 456 | //! <b>Complexity</b>: Constant. |
| 457 | iterator end() BOOST_NOEXCEPT_OR_NOTHROW; |
| 458 | |
| 459 | //! <b>Effects</b>: Returns a const_iterator to the end of the container. |
| 460 | //! |
| 461 | //! <b>Throws</b>: Nothing. |
| 462 | //! |
| 463 | //! <b>Complexity</b>: Constant. |
| 464 | const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 465 | |
| 466 | //! <b>Effects</b>: Returns a const_iterator to the end of the container. |
| 467 | //! |
| 468 | //! <b>Throws</b>: Nothing. |
| 469 | //! |
| 470 | //! <b>Complexity</b>: Constant. |
| 471 | const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 472 | |
| 473 | //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning |
| 474 | //! of the reversed container. |
| 475 | //! |
| 476 | //! <b>Throws</b>: Nothing. |
| 477 | //! |
| 478 | //! <b>Complexity</b>: Constant. |
| 479 | reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; |
| 480 | |
| 481 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning |
| 482 | //! of the reversed container. |
| 483 | //! |
| 484 | //! <b>Throws</b>: Nothing. |
| 485 | //! |
| 486 | //! <b>Complexity</b>: Constant. |
| 487 | const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 488 | |
| 489 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning |
| 490 | //! of the reversed container. |
| 491 | //! |
| 492 | //! <b>Throws</b>: Nothing. |
| 493 | //! |
| 494 | //! <b>Complexity</b>: Constant. |
| 495 | const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 496 | |
| 497 | //! <b>Effects</b>: Returns a reverse_iterator pointing to the end |
| 498 | //! of the reversed container. |
| 499 | //! |
| 500 | //! <b>Throws</b>: Nothing. |
| 501 | //! |
| 502 | //! <b>Complexity</b>: Constant. |
| 503 | reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; |
| 504 | |
| 505 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end |
| 506 | //! of the reversed container. |
| 507 | //! |
| 508 | //! <b>Throws</b>: Nothing. |
| 509 | //! |
| 510 | //! <b>Complexity</b>: Constant. |
| 511 | const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 512 | |
| 513 | //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end |
| 514 | //! of the reversed container. |
| 515 | //! |
| 516 | //! <b>Throws</b>: Nothing. |
| 517 | //! |
| 518 | //! <b>Complexity</b>: Constant. |
| 519 | const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 520 | |
| 521 | //! <b>Effects</b>: Returns true if the container contains no elements. |
| 522 | //! |
| 523 | //! <b>Throws</b>: Nothing. |
| 524 | //! |
| 525 | //! <b>Complexity</b>: Constant. |
| 526 | bool empty() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 527 | |
| 528 | //! <b>Effects</b>: Returns the number of the elements contained in the container. |
| 529 | //! |
| 530 | //! <b>Throws</b>: Nothing. |
| 531 | //! |
| 532 | //! <b>Complexity</b>: Constant. |
| 533 | size_type size() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 534 | |
| 535 | //! <b>Effects</b>: Returns the largest possible size of the container. |
| 536 | //! |
| 537 | //! <b>Throws</b>: Nothing. |
| 538 | //! |
| 539 | //! <b>Complexity</b>: Constant. |
| 540 | size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 541 | |
| 542 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 543 | |
| 544 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 545 | //! <b>Effects</b>: If there is no key equivalent to x in the map, inserts |
| 546 | //! value_type(x, T()) into the map. |
| 547 | //! |
| 548 | //! <b>Returns</b>: A reference to the mapped_type corresponding to x in *this. |
| 549 | //! |
| 550 | //! <b>Complexity</b>: Logarithmic. |
| 551 | mapped_type& operator[](const key_type &k); |
| 552 | |
| 553 | //! <b>Effects</b>: If there is no key equivalent to x in the map, inserts |
| 554 | //! value_type(boost::move(x), T()) into the map (the key is move-constructed) |
| 555 | //! |
| 556 | //! <b>Returns</b>: A reference to the mapped_type corresponding to x in *this. |
| 557 | //! |
| 558 | //! <b>Complexity</b>: Logarithmic. |
| 559 | mapped_type& operator[](key_type &&k); |
| 560 | #elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) |
| 561 | //in compilers like GCC 3.4, we can't catch temporaries |
| 562 | BOOST_CONTAINER_FORCEINLINE mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); } |
| 563 | BOOST_CONTAINER_FORCEINLINE mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); } |
| 564 | #else |
| 565 | BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) |
| 566 | #endif |
| 567 | |
| 568 | //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj) |
| 569 | //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value |
| 570 | //! as if by insert, constructing it from value_type(k, forward<M>(obj)). |
| 571 | //! |
| 572 | //! No iterators or references are invalidated. If the insertion is successful, pointers and references |
| 573 | //! to the element obtained while it is held in the node handle are invalidated, and pointers and |
| 574 | //! references obtained to that element before it was extracted become valid. |
| 575 | //! |
| 576 | //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment |
| 577 | //! took place. The iterator component is pointing at the element that was inserted or updated. |
| 578 | //! |
| 579 | //! <b>Complexity</b>: Logarithmic in the size of the container. |
| 580 | template <class M> |
| 581 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> insert_or_assign(const key_type& k, BOOST_FWD_REF(M) obj) |
| 582 | { return this->base_t::insert_or_assign(const_iterator(), k, ::boost::forward<M>(obj)); } |
| 583 | |
| 584 | //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj) |
| 585 | //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value |
| 586 | //! as if by insert, constructing it from value_type(k, move(obj)). |
| 587 | //! |
| 588 | //! No iterators or references are invalidated. If the insertion is successful, pointers and references |
| 589 | //! to the element obtained while it is held in the node handle are invalidated, and pointers and |
| 590 | //! references obtained to that element before it was extracted become valid. |
| 591 | //! |
| 592 | //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment |
| 593 | //! took place. The iterator component is pointing at the element that was inserted or updated. |
| 594 | //! |
| 595 | //! <b>Complexity</b>: Logarithmic in the size of the container. |
| 596 | template <class M> |
| 597 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> insert_or_assign(BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj) |
| 598 | { return this->base_t::insert_or_assign(const_iterator(), ::boost::move(k), ::boost::forward<M>(obj)); } |
| 599 | |
| 600 | //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj) |
| 601 | //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value |
| 602 | //! as if by insert, constructing it from value_type(k, forward<M>(obj)) and the new element |
| 603 | //! to the container as close as possible to the position just before hint. |
| 604 | //! |
| 605 | //! No iterators or references are invalidated. If the insertion is successful, pointers and references |
| 606 | //! to the element obtained while it is held in the node handle are invalidated, and pointers and |
| 607 | //! references obtained to that element before it was extracted become valid. |
| 608 | //! |
| 609 | //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment |
| 610 | //! took place. The iterator component is pointing at the element that was inserted or updated. |
| 611 | //! |
| 612 | //! <b>Complexity</b>: Logarithmic in the size of the container in general, but amortized constant if |
| 613 | //! the new element is inserted just before hint. |
| 614 | template <class M> |
| 615 | BOOST_CONTAINER_FORCEINLINE iterator insert_or_assign(const_iterator hint, const key_type& k, BOOST_FWD_REF(M) obj) |
| 616 | { return this->base_t::insert_or_assign(hint, k, ::boost::forward<M>(obj)); } |
| 617 | |
| 618 | //! <b>Effects</b>: If a key equivalent to k already exists in the container, assigns forward<M>(obj) |
| 619 | //! to the mapped_type corresponding to the key k. If the key does not exist, inserts the new value |
| 620 | //! as if by insert, constructing it from value_type(k, move(obj)) and the new element |
| 621 | //! to the container as close as possible to the position just before hint. |
| 622 | //! |
| 623 | //! No iterators or references are invalidated. If the insertion is successful, pointers and references |
| 624 | //! to the element obtained while it is held in the node handle are invalidated, and pointers and |
| 625 | //! references obtained to that element before it was extracted become valid. |
| 626 | //! |
| 627 | //! <b>Returns</b>: The bool component is true if the insertion took place and false if the assignment |
| 628 | //! took place. The iterator component is pointing at the element that was inserted or updated. |
| 629 | //! |
| 630 | //! <b>Complexity</b>: Logarithmic in the size of the container in general, but amortized constant if |
| 631 | //! the new element is inserted just before hint. |
| 632 | template <class M> |
| 633 | BOOST_CONTAINER_FORCEINLINE iterator insert_or_assign(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj) |
| 634 | { return this->base_t::insert_or_assign(hint, ::boost::move(k), ::boost::forward<M>(obj)); } |
| 635 | |
| 636 | //! <b>Returns</b>: A reference to the element whose key is equivalent to x. |
| 637 | //! Throws: An exception object of type out_of_range if no such element is present. |
| 638 | //! <b>Complexity</b>: logarithmic. |
| 639 | T& at(const key_type& k) |
| 640 | { |
| 641 | iterator i = this->find(k); |
| 642 | if(i == this->end()){ |
| 643 | throw_out_of_range("map::at key not found"); |
| 644 | } |
| 645 | return i->second; |
| 646 | } |
| 647 | |
| 648 | //! <b>Returns</b>: A reference to the element whose key is equivalent to x. |
| 649 | //! Throws: An exception object of type out_of_range if no such element is present. |
| 650 | //! <b>Complexity</b>: logarithmic. |
| 651 | const T& at(const key_type& k) const |
| 652 | { |
| 653 | const_iterator i = this->find(k); |
| 654 | if(i == this->end()){ |
| 655 | throw_out_of_range("map::at key not found"); |
| 656 | } |
| 657 | return i->second; |
| 658 | } |
| 659 | |
| 660 | ////////////////////////////////////////////// |
| 661 | // |
| 662 | // modifiers |
| 663 | // |
| 664 | ////////////////////////////////////////////// |
| 665 | |
| 666 | //! <b>Effects</b>: Inserts x if and only if there is no element in the container |
| 667 | //! with key equivalent to the key of x. |
| 668 | //! |
| 669 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 670 | //! if the insertion takes place, and the iterator component of the pair |
| 671 | //! points to the element with key equivalent to the key of x. |
| 672 | //! |
| 673 | //! <b>Complexity</b>: Logarithmic. |
| 674 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> insert(const value_type& x) |
| 675 | { return this->base_t::insert_unique(x); } |
| 676 | |
| 677 | //! <b>Effects</b>: Inserts a new value_type created from the pair if and only if |
| 678 | //! there is no element in the container with key equivalent to the key of x. |
| 679 | //! |
| 680 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 681 | //! if the insertion takes place, and the iterator component of the pair |
| 682 | //! points to the element with key equivalent to the key of x. |
| 683 | //! |
| 684 | //! <b>Complexity</b>: Logarithmic. |
| 685 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> insert(const nonconst_value_type& x) |
| 686 | { return this->try_emplace(x.first, x.second); } |
| 687 | |
| 688 | //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and |
| 689 | //! only if there is no element in the container with key equivalent to the key of x. |
| 690 | //! |
| 691 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 692 | //! if the insertion takes place, and the iterator component of the pair |
| 693 | //! points to the element with key equivalent to the key of x. |
| 694 | //! |
| 695 | //! <b>Complexity</b>: Logarithmic. |
| 696 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x) |
| 697 | { return this->try_emplace(boost::move(x.first), boost::move(x.second)); } |
| 698 | |
| 699 | //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and |
| 700 | //! only if there is no element in the container with key equivalent to the key of x. |
| 701 | //! |
| 702 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 703 | //! if the insertion takes place, and the iterator component of the pair |
| 704 | //! points to the element with key equivalent to the key of x. |
| 705 | //! |
| 706 | //! <b>Complexity</b>: Logarithmic. |
| 707 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x) |
| 708 | { return this->try_emplace(boost::move(x.first), boost::move(x.second)); } |
| 709 | |
| 710 | //! <b>Effects</b>: Move constructs a new value from x if and only if there is |
| 711 | //! no element in the container with key equivalent to the key of x. |
| 712 | //! |
| 713 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 714 | //! if the insertion takes place, and the iterator component of the pair |
| 715 | //! points to the element with key equivalent to the key of x. |
| 716 | //! |
| 717 | //! <b>Complexity</b>: Logarithmic. |
| 718 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x) |
| 719 | { return this->base_t::insert_unique(boost::move(x)); } |
| 720 | |
| 721 | //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is |
| 722 | //! no element in the container with key equivalent to the key of x. |
| 723 | //! p is a hint pointing to where the insert should start to search. |
| 724 | //! |
| 725 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 726 | //! to the key of x. |
| 727 | //! |
| 728 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 729 | //! is inserted right before p. |
| 730 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, const value_type& x) |
| 731 | { return this->base_t::insert_unique(p, x); } |
| 732 | |
| 733 | //! <b>Effects</b>: Move constructs a new value from x if and only if there is |
| 734 | //! no element in the container with key equivalent to the key of x. |
| 735 | //! p is a hint pointing to where the insert should start to search. |
| 736 | //! |
| 737 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 738 | //! to the key of x. |
| 739 | //! |
| 740 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 741 | //! is inserted right before p. |
| 742 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) |
| 743 | { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); } |
| 744 | |
| 745 | //! <b>Effects</b>: Move constructs a new value from x if and only if there is |
| 746 | //! no element in the container with key equivalent to the key of x. |
| 747 | //! p is a hint pointing to where the insert should start to search. |
| 748 | //! |
| 749 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 750 | //! to the key of x. |
| 751 | //! |
| 752 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 753 | //! is inserted right before p. |
| 754 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) |
| 755 | { return this->try_emplace(p, boost::move(x.first), boost::move(x.second)); } |
| 756 | |
| 757 | //! <b>Effects</b>: Inserts a copy of x in the container. |
| 758 | //! p is a hint pointing to where the insert should start to search. |
| 759 | //! |
| 760 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. |
| 761 | //! |
| 762 | //! <b>Complexity</b>: Logarithmic. |
| 763 | iterator insert(const_iterator p, const nonconst_value_type& x) |
| 764 | { return this->try_emplace(p, x.first, x.second); } |
| 765 | |
| 766 | //! <b>Effects</b>: Inserts an element move constructed from x in the container. |
| 767 | //! p is a hint pointing to where the insert should start to search. |
| 768 | //! |
| 769 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x. |
| 770 | //! |
| 771 | //! <b>Complexity</b>: Logarithmic. |
| 772 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) |
| 773 | { return this->base_t::insert_unique(p, boost::move(x)); } |
| 774 | |
| 775 | //! <b>Requires</b>: first, last are not iterators into *this. |
| 776 | //! |
| 777 | //! <b>Effects</b>: inserts each element from the range [first,last) if and only |
| 778 | //! if there is no element with key equivalent to the key of that element. |
| 779 | //! |
| 780 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last) |
| 781 | template <class InputIterator> |
| 782 | BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) |
| 783 | { this->base_t::insert_unique(first, last); } |
| 784 | |
| 785 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 786 | //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()) if and only |
| 787 | //! if there is no element with key equivalent to the key of that element. |
| 788 | //! |
| 789 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end()) |
| 790 | BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il) |
| 791 | { this->base_t::insert_unique(il.begin(), il.end()); } |
| 792 | #endif |
| 793 | |
| 794 | //! <b>Requires</b>: nh is empty or this->get_allocator() == nh.get_allocator(). |
| 795 | //! |
| 796 | //! <b>Effects</b>: If nh is empty, has no effect. Otherwise, inserts the element owned |
| 797 | //! by nh if and only if there is no element in the container with a key equivalent to nh.key(). |
| 798 | //! |
| 799 | //! <b>Returns</b>: If nh is empty, insert_return_type.inserted is false, insert_return_type.position |
| 800 | //! is end(), and insert_return_type.node is empty. Otherwise if the insertion took place, |
| 801 | //! insert_return_type.inserted is true, insert_return_type.position points to the inserted element, |
| 802 | //! and insert_return_type.node is empty; if the insertion failed, insert_return_type.inserted is |
| 803 | //! false, insert_return_type.node has the previous value of nh, and insert_return_type.position |
| 804 | //! points to an element with a key equivalent to nh.key(). |
| 805 | //! |
| 806 | //! <b>Complexity</b>: Logarithmic |
| 807 | insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 808 | { |
| 809 | typename base_t::node_type n(boost::move(nh)); |
| 810 | typename base_t::insert_return_type base_ret(this->base_t::insert_unique_node(boost::move(n))); |
| 811 | return insert_return_type (base_ret.inserted, base_ret.position, boost::move(base_ret.node)); |
| 812 | } |
| 813 | |
| 814 | //! <b>Effects</b>: Same as `insert(node_type && nh)` but the element is inserted as close as possible |
| 815 | //! to the position just prior to "hint". |
| 816 | //! |
| 817 | //! <b>Complexity</b>: logarithmic in general, but amortized constant if the element is inserted |
| 818 | //! right before "hint". |
| 819 | insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 820 | { |
| 821 | typename base_t::node_type n(boost::move(nh)); |
| 822 | typename base_t::insert_return_type base_ret(this->base_t::insert_unique_node(hint, boost::move(n))); |
| 823 | return insert_return_type (base_ret.inserted, base_ret.position, boost::move(base_ret.node)); |
| 824 | } |
| 825 | |
| 826 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 827 | |
| 828 | //! <b>Effects</b>: Inserts an object x of type T constructed with |
| 829 | //! std::forward<Args>(args)... in the container if and only if there is |
| 830 | //! no element in the container with an equivalent key. |
| 831 | //! p is a hint pointing to where the insert should start to search. |
| 832 | //! |
| 833 | //! <b>Returns</b>: The bool component of the returned pair is true if and only |
| 834 | //! if the insertion takes place, and the iterator component of the pair |
| 835 | //! points to the element with key equivalent to the key of x. |
| 836 | //! |
| 837 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 838 | //! is inserted right before p. |
| 839 | template <class... Args> |
| 840 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args) |
| 841 | { return this->base_t::emplace_unique(boost::forward<Args>(args)...); } |
| 842 | |
| 843 | //! <b>Effects</b>: Inserts an object of type T constructed with |
| 844 | //! std::forward<Args>(args)... in the container if and only if there is |
| 845 | //! no element in the container with an equivalent key. |
| 846 | //! p is a hint pointing to where the insert should start to search. |
| 847 | //! |
| 848 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 849 | //! to the key of x. |
| 850 | //! |
| 851 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 852 | //! is inserted right before p. |
| 853 | template <class... Args> |
| 854 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) |
| 855 | { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); } |
| 856 | |
| 857 | //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct, |
| 858 | //! forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...). |
| 859 | //! |
| 860 | //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise |
| 861 | //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k), |
| 862 | //! forward_as_tuple(forward<Args>(args)...). |
| 863 | //! |
| 864 | //! <b>Returns</b>: The bool component of the returned pair is true if and only if the |
| 865 | //! insertion took place. The returned iterator points to the map element whose key is equivalent to k. |
| 866 | //! |
| 867 | //! <b>Complexity</b>: Logarithmic. |
| 868 | template <class... Args> |
| 869 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> try_emplace(const key_type& k, BOOST_FWD_REF(Args)... args) |
| 870 | { return this->base_t::try_emplace(const_iterator(), k, boost::forward<Args>(args)...); } |
| 871 | |
| 872 | //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct, |
| 873 | //! forward_as_tuple(k), forward_as_tuple(forward<Args>(args)...). |
| 874 | //! |
| 875 | //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise |
| 876 | //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k), |
| 877 | //! forward_as_tuple(forward<Args>(args)...). |
| 878 | //! |
| 879 | //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k. |
| 880 | //! |
| 881 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if value |
| 882 | //! is inserted right before p. |
| 883 | template <class... Args> |
| 884 | BOOST_CONTAINER_FORCEINLINE iterator try_emplace(const_iterator hint, const key_type &k, BOOST_FWD_REF(Args)... args) |
| 885 | { return this->base_t::try_emplace(hint, k, boost::forward<Args>(args)...).first; } |
| 886 | |
| 887 | //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct, |
| 888 | //! forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...). |
| 889 | //! |
| 890 | //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise |
| 891 | //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)), |
| 892 | //! forward_as_tuple(forward<Args>(args)...). |
| 893 | //! |
| 894 | //! <b>Returns</b>: The bool component of the returned pair is true if and only if the |
| 895 | //! insertion took place. The returned iterator points to the map element whose key is equivalent to k. |
| 896 | //! |
| 897 | //! <b>Complexity</b>: Logarithmic. |
| 898 | template <class... Args> |
| 899 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> try_emplace(BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) |
| 900 | { return this->base_t::try_emplace(const_iterator(), boost::move(k), boost::forward<Args>(args)...); } |
| 901 | |
| 902 | //! <b>Requires</b>: value_type shall be EmplaceConstructible into map from piecewise_construct, |
| 903 | //! forward_as_tuple(move(k)), forward_as_tuple(forward<Args>(args)...). |
| 904 | //! |
| 905 | //! <b>Effects</b>: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise |
| 906 | //! inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(move(k)), |
| 907 | //! forward_as_tuple(forward<Args>(args)...). |
| 908 | //! |
| 909 | //! <b>Returns</b>: The returned iterator points to the map element whose key is equivalent to k. |
| 910 | //! |
| 911 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if value |
| 912 | //! is inserted right before p. |
| 913 | template <class... Args> |
| 914 | BOOST_CONTAINER_FORCEINLINE iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) |
| 915 | { return this->base_t::try_emplace(hint, boost::move(k), boost::forward<Args>(args)...).first; } |
| 916 | |
| 917 | #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 918 | |
| 919 | #define BOOST_CONTAINER_MAP_EMPLACE_CODE(N) \ |
| 920 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 921 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\ |
| 922 | { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\ |
| 923 | \ |
| 924 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 925 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 926 | { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 927 | \ |
| 928 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 929 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> try_emplace(const key_type& k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 930 | { return this->base_t::try_emplace(const_iterator(), k BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 931 | \ |
| 932 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 933 | BOOST_CONTAINER_FORCEINLINE iterator try_emplace(const_iterator hint, const key_type &k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 934 | { return this->base_t::try_emplace(hint, k BOOST_MOVE_I##N BOOST_MOVE_FWD##N).first; }\ |
| 935 | \ |
| 936 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 937 | BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> try_emplace(BOOST_RV_REF(key_type) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 938 | { return this->base_t::try_emplace(const_iterator(), boost::move(k) BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 939 | \ |
| 940 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 941 | BOOST_CONTAINER_FORCEINLINE iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 942 | { return this->base_t::try_emplace(hint, boost::move(k) BOOST_MOVE_I##N BOOST_MOVE_FWD##N).first; }\ |
| 943 | // |
| 944 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MAP_EMPLACE_CODE) |
| 945 | #undef BOOST_CONTAINER_MAP_EMPLACE_CODE |
| 946 | |
| 947 | #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 948 | |
| 949 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 950 | |
| 951 | //! <b>Effects</b>: Erases the element pointed to by p. |
| 952 | //! |
| 953 | //! <b>Returns</b>: Returns an iterator pointing to the element immediately |
| 954 | //! following q prior to the element being erased. If no such element exists, |
| 955 | //! returns end(). |
| 956 | //! |
| 957 | //! <b>Complexity</b>: Amortized constant time |
| 958 | iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW; |
| 959 | |
| 960 | //! <b>Effects</b>: Erases all elements in the container with key equivalent to x. |
| 961 | //! |
| 962 | //! <b>Returns</b>: Returns the number of erased elements. |
| 963 | //! |
| 964 | //! <b>Complexity</b>: log(size()) + count(k) |
| 965 | size_type erase(const key_type& x) BOOST_NOEXCEPT_OR_NOTHROW; |
| 966 | |
| 967 | //! <b>Effects</b>: Erases all the elements in the range [first, last). |
| 968 | //! |
| 969 | //! <b>Returns</b>: Returns last. |
| 970 | //! |
| 971 | //! <b>Complexity</b>: log(size())+N where N is the distance from first to last. |
| 972 | iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW; |
| 973 | |
| 974 | #endif |
| 975 | |
| 976 | //! <b>Effects</b>: Removes the first element in the container with key equivalent to k. |
| 977 | //! |
| 978 | //! <b>Returns</b>: A node_type owning the element if found, otherwise an empty node_type. |
| 979 | //! |
| 980 | //! <b>Complexity</b>: log(a.size()). |
| 981 | node_type extract(const key_type& k) |
| 982 | { |
| 983 | typename base_t::node_type base_nh(this->base_t::extract(k)); |
| 984 | node_type nh(boost::move(base_nh)); |
| 985 | return BOOST_MOVE_RET(node_type, nh); |
| 986 | } |
| 987 | |
| 988 | //! <b>Effects</b>: Removes the element pointed to by "position". |
| 989 | //! |
| 990 | //! <b>Returns</b>: A node_type owning the element, otherwise an empty node_type. |
| 991 | //! |
| 992 | //! <b>Complexity</b>: Amortized constant. |
| 993 | node_type extract(const_iterator position) |
| 994 | { |
| 995 | typename base_t::node_type base_nh(this->base_t::extract(position)); |
| 996 | node_type nh(boost::move(base_nh)); |
| 997 | return BOOST_MOVE_RET(node_type, nh); |
| 998 | } |
| 999 | |
| 1000 | //! <b>Requires</b>: this->get_allocator() == source.get_allocator(). |
| 1001 | //! |
| 1002 | //! <b>Effects</b>: Attempts to extract each element in source and insert it into a using |
| 1003 | //! the comparison object of *this. If there is an element in a with key equivalent to the |
| 1004 | //! key of an element from source, then that element is not extracted from source. |
| 1005 | //! |
| 1006 | //! <b>Postcondition</b>: Pointers and references to the transferred elements of source refer |
| 1007 | //! to those same elements but as members of *this. Iterators referring to the transferred |
| 1008 | //! elements will continue to refer to their elements, but they now behave as iterators into *this, |
| 1009 | //! not into source. |
| 1010 | //! |
| 1011 | //! <b>Throws</b>: Nothing unless the comparison object throws. |
| 1012 | //! |
| 1013 | //! <b>Complexity</b>: N log(a.size() + N) (N has the value source.size()) |
| 1014 | template<class C2> |
| 1015 | BOOST_CONTAINER_FORCEINLINE void merge(map<Key, T, C2, Allocator, Options>& source) |
| 1016 | { |
| 1017 | typedef dtl::tree |
| 1018 | <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t; |
| 1019 | this->merge_unique(static_cast<base2_t&>(source)); |
| 1020 | } |
| 1021 | |
| 1022 | //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&) |
| 1023 | template<class C2> |
| 1024 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG map<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1025 | { return this->merge(static_cast<map<Key, T, C2, Allocator, Options>&>(source)); } |
| 1026 | |
| 1027 | //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&) |
| 1028 | template<class C2> |
| 1029 | BOOST_CONTAINER_FORCEINLINE void merge(multimap<Key, T, C2, Allocator, Options>& source) |
| 1030 | { |
| 1031 | typedef dtl::tree |
| 1032 | <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t; |
| 1033 | this->base_t::merge_unique(static_cast<base2_t&>(source)); |
| 1034 | } |
| 1035 | |
| 1036 | //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&) |
| 1037 | template<class C2> |
| 1038 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multimap<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1039 | { return this->merge(static_cast<multimap<Key, T, C2, Allocator, Options>&>(source)); } |
| 1040 | |
| 1041 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1042 | //! <b>Effects</b>: Swaps the contents of *this and x. |
| 1043 | //! |
| 1044 | //! <b>Throws</b>: Nothing. |
| 1045 | //! |
| 1046 | //! <b>Complexity</b>: Constant. |
| 1047 | void swap(map& x) |
| 1048 | BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value |
| 1049 | && boost::container::dtl::is_nothrow_swappable<Compare>::value ) |
| 1050 | |
| 1051 | //! <b>Effects</b>: erase(a.begin(),a.end()). |
| 1052 | //! |
| 1053 | //! <b>Postcondition</b>: size() == 0. |
| 1054 | //! |
| 1055 | //! <b>Complexity</b>: linear in size(). |
| 1056 | void clear() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1057 | |
| 1058 | //! <b>Effects</b>: Returns the comparison object out |
| 1059 | //! of which a was constructed. |
| 1060 | //! |
| 1061 | //! <b>Complexity</b>: Constant. |
| 1062 | key_compare key_comp() const; |
| 1063 | |
| 1064 | //! <b>Effects</b>: Returns an object of value_compare constructed out |
| 1065 | //! of the comparison object. |
| 1066 | //! |
| 1067 | //! <b>Complexity</b>: Constant. |
| 1068 | value_compare value_comp() const; |
| 1069 | |
| 1070 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 1071 | //! equivalent to x, or end() if such an element is not found. |
| 1072 | //! |
| 1073 | //! <b>Complexity</b>: Logarithmic. |
| 1074 | iterator find(const key_type& x); |
| 1075 | |
| 1076 | //! <b>Returns</b>: A const_iterator pointing to an element with the key |
| 1077 | //! equivalent to x, or end() if such an element is not found. |
| 1078 | //! |
| 1079 | //! <b>Complexity</b>: Logarithmic. |
| 1080 | const_iterator find(const key_type& x) const; |
| 1081 | |
| 1082 | //! <b>Requires</b>: This overload is available only if |
| 1083 | //! key_compare::is_transparent exists. |
| 1084 | //! |
| 1085 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 1086 | //! equivalent to x, or end() if such an element is not found. |
| 1087 | //! |
| 1088 | //! <b>Complexity</b>: Logarithmic. |
| 1089 | template<typename K> |
| 1090 | iterator find(const K& x); |
| 1091 | |
| 1092 | //! <b>Requires</b>: This overload is available only if |
| 1093 | //! key_compare::is_transparent exists. |
| 1094 | //! |
| 1095 | //! <b>Returns</b>: A const_iterator pointing to an element with the key |
| 1096 | //! equivalent to x, or end() if such an element is not found. |
| 1097 | //! |
| 1098 | //! <b>Complexity</b>: Logarithmic. |
| 1099 | template<typename K> |
| 1100 | const_iterator find(const K& x) const; |
| 1101 | |
| 1102 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1103 | |
| 1104 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 1105 | //! |
| 1106 | //! <b>Complexity</b>: log(size())+count(k) |
| 1107 | BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const |
| 1108 | { return static_cast<size_type>(this->find(x) != this->cend()); } |
| 1109 | |
| 1110 | //! <b>Requires</b>: This overload is available only if |
| 1111 | //! key_compare::is_transparent exists. |
| 1112 | //! |
| 1113 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 1114 | //! |
| 1115 | //! <b>Complexity</b>: log(size())+count(k) |
| 1116 | template<typename K> |
| 1117 | BOOST_CONTAINER_FORCEINLINE size_type count(const K& x) const |
| 1118 | { return static_cast<size_type>(this->find(x) != this->cend()); } |
| 1119 | |
| 1120 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1121 | |
| 1122 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 1123 | //! than k, or a.end() if such an element is not found. |
| 1124 | //! |
| 1125 | //! <b>Complexity</b>: Logarithmic |
| 1126 | iterator lower_bound(const key_type& x); |
| 1127 | |
| 1128 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 1129 | //! less than k, or a.end() if such an element is not found. |
| 1130 | //! |
| 1131 | //! <b>Complexity</b>: Logarithmic |
| 1132 | const_iterator lower_bound(const key_type& x) const; |
| 1133 | |
| 1134 | //! <b>Requires</b>: This overload is available only if |
| 1135 | //! key_compare::is_transparent exists. |
| 1136 | //! |
| 1137 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 1138 | //! than k, or a.end() if such an element is not found. |
| 1139 | //! |
| 1140 | //! <b>Complexity</b>: Logarithmic |
| 1141 | template<typename K> |
| 1142 | iterator lower_bound(const K& x); |
| 1143 | |
| 1144 | //! <b>Requires</b>: This overload is available only if |
| 1145 | //! key_compare::is_transparent exists. |
| 1146 | //! |
| 1147 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 1148 | //! less than k, or a.end() if such an element is not found. |
| 1149 | //! |
| 1150 | //! <b>Complexity</b>: Logarithmic |
| 1151 | template<typename K> |
| 1152 | const_iterator lower_bound(const K& x) const; |
| 1153 | |
| 1154 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 1155 | //! than x, or end() if such an element is not found. |
| 1156 | //! |
| 1157 | //! <b>Complexity</b>: Logarithmic |
| 1158 | iterator upper_bound(const key_type& x); |
| 1159 | |
| 1160 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 1161 | //! less than x, or end() if such an element is not found. |
| 1162 | //! |
| 1163 | //! <b>Complexity</b>: Logarithmic |
| 1164 | const_iterator upper_bound(const key_type& x) const; |
| 1165 | |
| 1166 | //! <b>Requires</b>: This overload is available only if |
| 1167 | //! key_compare::is_transparent exists. |
| 1168 | //! |
| 1169 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 1170 | //! than x, or end() if such an element is not found. |
| 1171 | //! |
| 1172 | //! <b>Complexity</b>: Logarithmic |
| 1173 | template<typename K> |
| 1174 | iterator upper_bound(const K& x); |
| 1175 | |
| 1176 | //! <b>Requires</b>: This overload is available only if |
| 1177 | //! key_compare::is_transparent exists. |
| 1178 | //! |
| 1179 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 1180 | //! less than x, or end() if such an element is not found. |
| 1181 | //! |
| 1182 | //! <b>Complexity</b>: Logarithmic |
| 1183 | template<typename K> |
| 1184 | const_iterator upper_bound(const K& x) const; |
| 1185 | |
| 1186 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 1187 | //! |
| 1188 | //! <b>Complexity</b>: Logarithmic |
| 1189 | std::pair<iterator,iterator> equal_range(const key_type& x); |
| 1190 | |
| 1191 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 1192 | //! |
| 1193 | //! <b>Complexity</b>: Logarithmic |
| 1194 | std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const; |
| 1195 | |
| 1196 | //! <b>Requires</b>: This overload is available only if |
| 1197 | //! key_compare::is_transparent exists. |
| 1198 | //! |
| 1199 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 1200 | //! |
| 1201 | //! <b>Complexity</b>: Logarithmic |
| 1202 | template<typename K> |
| 1203 | std::pair<iterator,iterator> equal_range(const K& x); |
| 1204 | |
| 1205 | //! <b>Requires</b>: This overload is available only if |
| 1206 | //! key_compare::is_transparent exists. |
| 1207 | //! |
| 1208 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 1209 | //! |
| 1210 | //! <b>Complexity</b>: Logarithmic |
| 1211 | template<typename K> |
| 1212 | std::pair<const_iterator,const_iterator> equal_range(const K& x) const; |
| 1213 | |
| 1214 | //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees. |
| 1215 | //! |
| 1216 | //! <b>Complexity</b>: Linear |
| 1217 | void rebalance(); |
| 1218 | |
| 1219 | //! <b>Effects</b>: Returns true if x and y are equal |
| 1220 | //! |
| 1221 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1222 | friend bool operator==(const map& x, const map& y); |
| 1223 | |
| 1224 | //! <b>Effects</b>: Returns true if x and y are unequal |
| 1225 | //! |
| 1226 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1227 | friend bool operator!=(const map& x, const map& y); |
| 1228 | |
| 1229 | //! <b>Effects</b>: Returns true if x is less than y |
| 1230 | //! |
| 1231 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1232 | friend bool operator<(const map& x, const map& y); |
| 1233 | |
| 1234 | //! <b>Effects</b>: Returns true if x is greater than y |
| 1235 | //! |
| 1236 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1237 | friend bool operator>(const map& x, const map& y); |
| 1238 | |
| 1239 | //! <b>Effects</b>: Returns true if x is equal or less than y |
| 1240 | //! |
| 1241 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1242 | friend bool operator<=(const map& x, const map& y); |
| 1243 | |
| 1244 | //! <b>Effects</b>: Returns true if x is equal or greater than y |
| 1245 | //! |
| 1246 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 1247 | friend bool operator>=(const map& x, const map& y); |
| 1248 | |
| 1249 | //! <b>Effects</b>: x.swap(y) |
| 1250 | //! |
| 1251 | //! <b>Complexity</b>: Constant. |
| 1252 | friend void swap(map& x, map& y); |
| 1253 | |
| 1254 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1255 | |
| 1256 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1257 | private: |
| 1258 | template<class KeyConvertible> |
| 1259 | BOOST_CONTAINER_FORCEINLINE mapped_type& priv_subscript(BOOST_FWD_REF(KeyConvertible) k) |
| 1260 | { |
| 1261 | return this->try_emplace(boost::forward<KeyConvertible>(k)).first->second; |
| 1262 | } |
| 1263 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1264 | }; |
| 1265 | |
| 1266 | #if __cplusplus >= 201703L |
| 1267 | |
| 1268 | template <typename InputIterator> |
| 1269 | map(InputIterator, InputIterator) -> |
| 1270 | map< typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1271 | , typename iterator_traits<InputIterator>::value_type::second_type>; |
| 1272 | |
| 1273 | template <typename InputIterator, typename Allocator> |
| 1274 | map(InputIterator, InputIterator, Allocator const&) -> |
| 1275 | map< typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1276 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1277 | , std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type> |
| 1278 | , Allocator>; |
| 1279 | |
| 1280 | template <typename InputIterator, typename Compare> |
| 1281 | map(InputIterator, InputIterator, Compare const&) -> |
| 1282 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1283 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1284 | , Compare>; |
| 1285 | |
| 1286 | template <typename InputIterator, typename Compare, typename Allocator> |
| 1287 | map(InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 1288 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1289 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1290 | , Compare |
| 1291 | , Allocator>; |
| 1292 | |
| 1293 | template <typename InputIterator> |
| 1294 | map(ordered_unique_range_t, InputIterator, InputIterator) -> |
| 1295 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1296 | , typename iterator_traits<InputIterator>::value_type::second_type>; |
| 1297 | |
| 1298 | template <typename InputIterator, typename Allocator> |
| 1299 | map(ordered_unique_range_t, InputIterator, InputIterator, Allocator const&) -> |
| 1300 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1301 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1302 | , std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type> |
| 1303 | , Allocator>; |
| 1304 | |
| 1305 | template <typename InputIterator, typename Compare> |
| 1306 | map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&) -> |
| 1307 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1308 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1309 | , Compare>; |
| 1310 | |
| 1311 | template <typename InputIterator, typename Compare, typename Allocator> |
| 1312 | map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 1313 | map< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 1314 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 1315 | , Compare |
| 1316 | , Allocator>; |
| 1317 | |
| 1318 | #endif |
| 1319 | |
| 1320 | |
| 1321 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1322 | |
| 1323 | } //namespace container { |
| 1324 | |
| 1325 | //!has_trivial_destructor_after_move<> == true_type |
| 1326 | //!specialization for optimizations |
| 1327 | template <class Key, class T, class Compare, class Allocator> |
| 1328 | struct has_trivial_destructor_after_move<boost::container::map<Key, T, Compare, Allocator> > |
| 1329 | { |
| 1330 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 1331 | static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && |
| 1332 | ::boost::has_trivial_destructor_after_move<pointer>::value && |
| 1333 | ::boost::has_trivial_destructor_after_move<Compare>::value; |
| 1334 | }; |
| 1335 | |
| 1336 | namespace container { |
| 1337 | |
| 1338 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1339 | |
| 1340 | #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1341 | |
| 1342 | //! A multimap is a kind of associative container that supports equivalent keys |
| 1343 | //! (possibly containing multiple copies of the same key value) and provides for |
| 1344 | //! fast retrieval of values of another type T based on the keys. The multimap class |
| 1345 | //! supports bidirectional iterators. |
| 1346 | //! |
| 1347 | //! A multimap satisfies all of the requirements of a container and of a reversible |
| 1348 | //! container and of an associative container. The <code>value_type</code> stored |
| 1349 | //! by this container is the value_type is std::pair<const Key, T>. |
| 1350 | //! |
| 1351 | //! \tparam Key is the key_type of the map |
| 1352 | //! \tparam Value is the <code>mapped_type</code> |
| 1353 | //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>). |
| 1354 | //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s |
| 1355 | //! (e.g. <i>allocator< std::pair<const Key, T> > </i>). |
| 1356 | //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options. |
| 1357 | template < class Key, class T, class Compare = std::less<Key> |
| 1358 | , class Allocator = new_allocator< std::pair< const Key, T> >, class Options = tree_assoc_defaults> |
| 1359 | #else |
| 1360 | template <class Key, class T, class Compare, class Allocator, class Options> |
| 1361 | #endif |
| 1362 | class multimap |
| 1363 | ///@cond |
| 1364 | : public dtl::tree |
| 1365 | < std::pair<const Key, T> |
| 1366 | , dtl::select1st<Key> |
| 1367 | , Compare, Allocator, Options> |
| 1368 | ///@endcond |
| 1369 | { |
| 1370 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1371 | private: |
| 1372 | BOOST_COPYABLE_AND_MOVABLE(multimap) |
| 1373 | |
| 1374 | typedef dtl::select1st<Key> select_1st_t; |
| 1375 | typedef std::pair<const Key, T> value_type_impl; |
| 1376 | typedef dtl::tree |
| 1377 | <value_type_impl, select_1st_t, Compare, Allocator, Options> base_t; |
| 1378 | typedef dtl::pair <Key, T> movable_value_type_impl; |
| 1379 | typedef typename base_t::value_compare value_compare_impl; |
| 1380 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 1381 | |
| 1382 | typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type; |
| 1383 | |
| 1384 | public: |
| 1385 | ////////////////////////////////////////////// |
| 1386 | // |
| 1387 | // types |
| 1388 | // |
| 1389 | ////////////////////////////////////////////// |
| 1390 | |
| 1391 | typedef Key key_type; |
| 1392 | typedef T mapped_type; |
| 1393 | typedef typename boost::container::allocator_traits<Allocator>::value_type value_type; |
| 1394 | typedef typename boost::container::allocator_traits<Allocator>::pointer pointer; |
| 1395 | typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer; |
| 1396 | typedef typename boost::container::allocator_traits<Allocator>::reference reference; |
| 1397 | typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference; |
| 1398 | typedef typename boost::container::allocator_traits<Allocator>::size_type size_type; |
| 1399 | typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type; |
| 1400 | typedef Allocator allocator_type; |
| 1401 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; |
| 1402 | typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; |
| 1403 | typedef Compare key_compare; |
| 1404 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; |
| 1405 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; |
| 1406 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; |
| 1407 | typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; |
| 1408 | typedef std::pair<key_type, mapped_type> nonconst_value_type; |
| 1409 | typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; |
| 1410 | typedef BOOST_CONTAINER_IMPDEF(node_handle< |
| 1411 | typename base_t::stored_allocator_type |
| 1412 | BOOST_MOVE_I pair_key_mapped_of_value |
| 1413 | <key_type BOOST_MOVE_I mapped_type> >) node_type; |
| 1414 | |
| 1415 | //allocator_type::value_type type must be std::pair<CONST Key, T> |
| 1416 | BOOST_STATIC_ASSERT((dtl::is_same<typename allocator_type::value_type, std::pair<const Key, T> >::value)); |
| 1417 | |
| 1418 | ////////////////////////////////////////////// |
| 1419 | // |
| 1420 | // construct/copy/destroy |
| 1421 | // |
| 1422 | ////////////////////////////////////////////// |
| 1423 | |
| 1424 | //! <b>Effects</b>: Default constructs an empty multimap. |
| 1425 | //! |
| 1426 | //! <b>Complexity</b>: Constant. |
| 1427 | BOOST_CONTAINER_FORCEINLINE multimap() |
| 1428 | BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<Allocator>::value && |
| 1429 | dtl::is_nothrow_default_constructible<Compare>::value) |
| 1430 | : base_t() |
| 1431 | {} |
| 1432 | |
| 1433 | //! <b>Effects</b>: Constructs an empty multimap using the specified allocator |
| 1434 | //! object and allocator. |
| 1435 | //! |
| 1436 | //! <b>Complexity</b>: Constant. |
| 1437 | BOOST_CONTAINER_FORCEINLINE explicit multimap(const allocator_type& a) |
| 1438 | : base_t(a) |
| 1439 | {} |
| 1440 | |
| 1441 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison. |
| 1442 | //! |
| 1443 | //! <b>Complexity</b>: Constant. |
| 1444 | BOOST_CONTAINER_FORCEINLINE explicit multimap(const Compare& comp) |
| 1445 | : base_t(comp) |
| 1446 | {} |
| 1447 | |
| 1448 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison and allocator. |
| 1449 | //! |
| 1450 | //! <b>Complexity</b>: Constant. |
| 1451 | BOOST_CONTAINER_FORCEINLINE multimap(const Compare& comp, const allocator_type& a) |
| 1452 | : base_t(comp, a) |
| 1453 | {} |
| 1454 | |
| 1455 | //! <b>Effects</b>: Constructs an empty multimap and |
| 1456 | //! inserts elements from the range [first ,last ). |
| 1457 | //! |
| 1458 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1459 | //! the predicate and otherwise N logN, where N is last - first. |
| 1460 | template <class InputIterator> |
| 1461 | BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last) |
| 1462 | : base_t(false, first, last) |
| 1463 | {} |
| 1464 | |
| 1465 | //! <b>Effects</b>: Constructs an empty multimap using the specified |
| 1466 | //! allocator, and inserts elements from the range [first ,last ). |
| 1467 | //! |
| 1468 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1469 | //! the predicate and otherwise N logN, where N is last - first. |
| 1470 | template <class InputIterator> |
| 1471 | BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, const allocator_type& a) |
| 1472 | : base_t(false, first, last, Compare(), a) |
| 1473 | {} |
| 1474 | |
| 1475 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and |
| 1476 | //! inserts elements from the range [first ,last ). |
| 1477 | //! |
| 1478 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1479 | //! the predicate and otherwise N logN, where N is last - first. |
| 1480 | template <class InputIterator> |
| 1481 | BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, const Compare& comp) |
| 1482 | : base_t(false, first, last, comp) |
| 1483 | {} |
| 1484 | |
| 1485 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object |
| 1486 | //! and allocator, and inserts elements from the range [first ,last ). |
| 1487 | //! |
| 1488 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1489 | //! the predicate and otherwise N logN, where N is last - first. |
| 1490 | template <class InputIterator> |
| 1491 | BOOST_CONTAINER_FORCEINLINE multimap(InputIterator first, InputIterator last, |
| 1492 | const Compare& comp, const allocator_type& a) |
| 1493 | : base_t(false, first, last, comp, a) |
| 1494 | {} |
| 1495 | |
| 1496 | //! <b>Effects</b>: Constructs an empty multimap and |
| 1497 | //! inserts elements from the ordered range [first ,last). This function |
| 1498 | //! is more efficient than the normal range creation for ordered ranges. |
| 1499 | //! |
| 1500 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1501 | //! |
| 1502 | //! <b>Complexity</b>: Linear in N. |
| 1503 | //! |
| 1504 | //! <b>Note</b>: Non-standard extension. |
| 1505 | template <class InputIterator> |
| 1506 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last) |
| 1507 | : base_t(ordered_range, first, last) |
| 1508 | {} |
| 1509 | |
| 1510 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and |
| 1511 | //! inserts elements from the ordered range [first ,last). This function |
| 1512 | //! is more efficient than the normal range creation for ordered ranges. |
| 1513 | //! |
| 1514 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1515 | //! |
| 1516 | //! <b>Complexity</b>: Linear in N. |
| 1517 | //! |
| 1518 | //! <b>Note</b>: Non-standard extension. |
| 1519 | template <class InputIterator> |
| 1520 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp) |
| 1521 | : base_t(ordered_range, first, last, comp) |
| 1522 | {} |
| 1523 | |
| 1524 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and |
| 1525 | //! allocator, and inserts elements from the ordered range [first ,last). This function |
| 1526 | //! is more efficient than the normal range creation for ordered ranges. |
| 1527 | //! |
| 1528 | //! <b>Requires</b>: [first ,last) must be ordered according to the predicate. |
| 1529 | //! |
| 1530 | //! <b>Complexity</b>: Linear in N. |
| 1531 | //! |
| 1532 | //! <b>Note</b>: Non-standard extension. |
| 1533 | template <class InputIterator> |
| 1534 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, |
| 1535 | const allocator_type& a) |
| 1536 | : base_t(ordered_range, first, last, comp, a) |
| 1537 | {} |
| 1538 | |
| 1539 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1540 | //! <b>Effects</b>: Constructs an empty multimap and |
| 1541 | //! and inserts elements from the range [il.begin(), il.end()). |
| 1542 | //! |
| 1543 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1544 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 1545 | BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list<value_type> il) |
| 1546 | : base_t(false, il.begin(), il.end()) |
| 1547 | {} |
| 1548 | |
| 1549 | //! <b>Effects</b>: Constructs an empty multimap using the specified |
| 1550 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 1551 | //! |
| 1552 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1553 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 1554 | BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list<value_type> il, const allocator_type& a) |
| 1555 | : base_t(false, il.begin(), il.end(), Compare(), a) |
| 1556 | {} |
| 1557 | |
| 1558 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and |
| 1559 | //! inserts elements from the range [il.begin(), il.end()). |
| 1560 | //! |
| 1561 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1562 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 1563 | BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list<value_type> il, const Compare& comp) |
| 1564 | : base_t(false, il.begin(), il.end(), comp) |
| 1565 | {} |
| 1566 | |
| 1567 | //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and |
| 1568 | //! allocator, and inserts elements from the range [il.begin(), il.end()). |
| 1569 | //! |
| 1570 | //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using |
| 1571 | //! the predicate and otherwise N logN, where N is il.first() - il.end(). |
| 1572 | BOOST_CONTAINER_FORCEINLINE multimap(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 1573 | : base_t(false, il.begin(), il.end(), comp, a) |
| 1574 | {} |
| 1575 | |
| 1576 | |
| 1577 | //! <b>Effects</b>: Constructs an empty map and |
| 1578 | //! inserts elements from the ordered range [il.begin(), il.end()). This function |
| 1579 | //! is more efficient than the normal range creation for ordered ranges. |
| 1580 | //! |
| 1581 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate. |
| 1582 | //! |
| 1583 | //! <b>Complexity</b>: Linear in N. |
| 1584 | //! |
| 1585 | //! <b>Note</b>: Non-standard extension. |
| 1586 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list<value_type> il) |
| 1587 | : base_t(ordered_range, il.begin(), il.end()) |
| 1588 | {} |
| 1589 | |
| 1590 | //! <b>Effects</b>: Constructs an empty map using the specified comparison object and |
| 1591 | //! inserts elements from the ordered range [il.begin(), il.end()). This function |
| 1592 | //! is more efficient than the normal range creation for ordered ranges. |
| 1593 | //! |
| 1594 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate. |
| 1595 | //! |
| 1596 | //! <b>Complexity</b>: Linear in N. |
| 1597 | //! |
| 1598 | //! <b>Note</b>: Non-standard extension. |
| 1599 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp) |
| 1600 | : base_t(ordered_range, il.begin(), il.end(), comp) |
| 1601 | {} |
| 1602 | |
| 1603 | //! <b>Effects</b>: Constructs an empty map and |
| 1604 | //! inserts elements from the ordered range [il.begin(), il.end()). This function |
| 1605 | //! is more efficient than the normal range creation for ordered ranges. |
| 1606 | //! |
| 1607 | //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate. |
| 1608 | //! |
| 1609 | //! <b>Complexity</b>: Linear in N. |
| 1610 | //! |
| 1611 | //! <b>Note</b>: Non-standard extension. |
| 1612 | BOOST_CONTAINER_FORCEINLINE multimap(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a) |
| 1613 | : base_t(ordered_range, il.begin(), il.end(), comp, a) |
| 1614 | {} |
| 1615 | |
| 1616 | #endif |
| 1617 | |
| 1618 | //! <b>Effects</b>: Copy constructs a multimap. |
| 1619 | //! |
| 1620 | //! <b>Complexity</b>: Linear in x.size(). |
| 1621 | BOOST_CONTAINER_FORCEINLINE multimap(const multimap& x) |
| 1622 | : base_t(static_cast<const base_t&>(x)) |
| 1623 | {} |
| 1624 | |
| 1625 | //! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources. |
| 1626 | //! |
| 1627 | //! <b>Complexity</b>: Constant. |
| 1628 | //! |
| 1629 | //! <b>Postcondition</b>: x is emptied. |
| 1630 | BOOST_CONTAINER_FORCEINLINE multimap(BOOST_RV_REF(multimap) x) |
| 1631 | BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value) |
| 1632 | : base_t(BOOST_MOVE_BASE(base_t, x)) |
| 1633 | {} |
| 1634 | |
| 1635 | //! <b>Effects</b>: Copy constructs a multimap. |
| 1636 | //! |
| 1637 | //! <b>Complexity</b>: Linear in x.size(). |
| 1638 | BOOST_CONTAINER_FORCEINLINE multimap(const multimap& x, const allocator_type &a) |
| 1639 | : base_t(static_cast<const base_t&>(x), a) |
| 1640 | {} |
| 1641 | |
| 1642 | //! <b>Effects</b>: Move constructs a multimap using the specified allocator. |
| 1643 | //! Constructs *this using x's resources. |
| 1644 | //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise. |
| 1645 | //! |
| 1646 | //! <b>Postcondition</b>: x is emptied. |
| 1647 | BOOST_CONTAINER_FORCEINLINE multimap(BOOST_RV_REF(multimap) x, const allocator_type &a) |
| 1648 | : base_t(BOOST_MOVE_BASE(base_t, x), a) |
| 1649 | {} |
| 1650 | |
| 1651 | //! <b>Effects</b>: Makes *this a copy of x. |
| 1652 | //! |
| 1653 | //! <b>Complexity</b>: Linear in x.size(). |
| 1654 | BOOST_CONTAINER_FORCEINLINE multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x) |
| 1655 | { return static_cast<multimap&>(this->base_t::operator=(static_cast<const base_t&>(x))); } |
| 1656 | |
| 1657 | //! <b>Effects</b>: this->swap(x.get()). |
| 1658 | //! |
| 1659 | //! <b>Complexity</b>: Constant. |
| 1660 | BOOST_CONTAINER_FORCEINLINE multimap& operator=(BOOST_RV_REF(multimap) x) |
| 1661 | BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value || |
| 1662 | allocator_traits_type::is_always_equal::value) && |
| 1663 | boost::container::dtl::is_nothrow_move_assignable<Compare>::value) |
| 1664 | { return static_cast<multimap&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } |
| 1665 | |
| 1666 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1667 | //! <b>Effects</b>: Assign content of il to *this. |
| 1668 | //! |
| 1669 | BOOST_CONTAINER_FORCEINLINE multimap& operator=(std::initializer_list<value_type> il) |
| 1670 | { |
| 1671 | this->clear(); |
| 1672 | insert(il.begin(), il.end()); |
| 1673 | return *this; |
| 1674 | } |
| 1675 | #endif |
| 1676 | |
| 1677 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1678 | |
| 1679 | //! @copydoc ::boost::container::set::get_allocator() |
| 1680 | allocator_type get_allocator() const; |
| 1681 | |
| 1682 | //! @copydoc ::boost::container::set::get_stored_allocator() |
| 1683 | stored_allocator_type &get_stored_allocator(); |
| 1684 | |
| 1685 | //! @copydoc ::boost::container::set::get_stored_allocator() const |
| 1686 | const stored_allocator_type &get_stored_allocator() const; |
| 1687 | |
| 1688 | //! @copydoc ::boost::container::set::begin() |
| 1689 | iterator begin(); |
| 1690 | |
| 1691 | //! @copydoc ::boost::container::set::begin() const |
| 1692 | const_iterator begin() const; |
| 1693 | |
| 1694 | //! @copydoc ::boost::container::set::cbegin() const |
| 1695 | const_iterator cbegin() const; |
| 1696 | |
| 1697 | //! @copydoc ::boost::container::set::end() |
| 1698 | iterator end() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1699 | |
| 1700 | //! @copydoc ::boost::container::set::end() const |
| 1701 | const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1702 | |
| 1703 | //! @copydoc ::boost::container::set::cend() const |
| 1704 | const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1705 | |
| 1706 | //! @copydoc ::boost::container::set::rbegin() |
| 1707 | reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1708 | |
| 1709 | //! @copydoc ::boost::container::set::rbegin() const |
| 1710 | const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1711 | |
| 1712 | //! @copydoc ::boost::container::set::crbegin() const |
| 1713 | const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1714 | |
| 1715 | //! @copydoc ::boost::container::set::rend() |
| 1716 | reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1717 | |
| 1718 | //! @copydoc ::boost::container::set::rend() const |
| 1719 | const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1720 | |
| 1721 | //! @copydoc ::boost::container::set::crend() const |
| 1722 | const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; |
| 1723 | |
| 1724 | //! @copydoc ::boost::container::set::empty() const |
| 1725 | bool empty() const; |
| 1726 | |
| 1727 | //! @copydoc ::boost::container::set::size() const |
| 1728 | size_type size() const; |
| 1729 | |
| 1730 | //! @copydoc ::boost::container::set::max_size() const |
| 1731 | size_type max_size() const; |
| 1732 | |
| 1733 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1734 | |
| 1735 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1736 | |
| 1737 | //! <b>Effects</b>: Inserts an object of type T constructed with |
| 1738 | //! std::forward<Args>(args)... in the container. |
| 1739 | //! p is a hint pointing to where the insert should start to search. |
| 1740 | //! |
| 1741 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1742 | //! to the key of x. |
| 1743 | //! |
| 1744 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1745 | //! is inserted right before p. |
| 1746 | template <class... Args> |
| 1747 | BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_FWD_REF(Args)... args) |
| 1748 | { return this->base_t::emplace_equal(boost::forward<Args>(args)...); } |
| 1749 | |
| 1750 | //! <b>Effects</b>: Inserts an object of type T constructed with |
| 1751 | //! std::forward<Args>(args)... in the container. |
| 1752 | //! p is a hint pointing to where the insert should start to search. |
| 1753 | //! |
| 1754 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1755 | //! to the key of x. |
| 1756 | //! |
| 1757 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1758 | //! is inserted right before p. |
| 1759 | template <class... Args> |
| 1760 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) |
| 1761 | { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); } |
| 1762 | |
| 1763 | #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 1764 | |
| 1765 | #define BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE(N) \ |
| 1766 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 1767 | BOOST_CONTAINER_FORCEINLINE iterator emplace(BOOST_MOVE_UREF##N)\ |
| 1768 | { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\ |
| 1769 | \ |
| 1770 | BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
| 1771 | BOOST_CONTAINER_FORCEINLINE iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ |
| 1772 | { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ |
| 1773 | // |
| 1774 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE) |
| 1775 | #undef BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE |
| 1776 | |
| 1777 | #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 1778 | |
| 1779 | //! <b>Effects</b>: Inserts x and returns the iterator pointing to the |
| 1780 | //! newly inserted element. |
| 1781 | //! |
| 1782 | //! <b>Complexity</b>: Logarithmic. |
| 1783 | BOOST_CONTAINER_FORCEINLINE iterator insert(const value_type& x) |
| 1784 | { return this->base_t::insert_equal(x); } |
| 1785 | |
| 1786 | //! <b>Effects</b>: Inserts a new value constructed from x and returns |
| 1787 | //! the iterator pointing to the newly inserted element. |
| 1788 | //! |
| 1789 | //! <b>Complexity</b>: Logarithmic. |
| 1790 | BOOST_CONTAINER_FORCEINLINE iterator insert(const nonconst_value_type& x) |
| 1791 | { return this->base_t::emplace_equal(x); } |
| 1792 | |
| 1793 | //! <b>Effects</b>: Inserts a new value move-constructed from x and returns |
| 1794 | //! the iterator pointing to the newly inserted element. |
| 1795 | //! |
| 1796 | //! <b>Complexity</b>: Logarithmic. |
| 1797 | BOOST_CONTAINER_FORCEINLINE iterator insert(BOOST_RV_REF(nonconst_value_type) x) |
| 1798 | { return this->base_t::emplace_equal(boost::move(x)); } |
| 1799 | |
| 1800 | //! <b>Effects</b>: Inserts a new value move-constructed from x and returns |
| 1801 | //! the iterator pointing to the newly inserted element. |
| 1802 | //! |
| 1803 | //! <b>Complexity</b>: Logarithmic. |
| 1804 | iterator insert(BOOST_RV_REF(movable_value_type) x) |
| 1805 | { return this->base_t::emplace_equal(boost::move(x)); } |
| 1806 | |
| 1807 | //! <b>Effects</b>: Inserts a copy of x in the container. |
| 1808 | //! p is a hint pointing to where the insert should start to search. |
| 1809 | //! |
| 1810 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1811 | //! to the key of x. |
| 1812 | //! |
| 1813 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1814 | //! is inserted right before p. |
| 1815 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, const value_type& x) |
| 1816 | { return this->base_t::insert_equal(p, x); } |
| 1817 | |
| 1818 | //! <b>Effects</b>: Inserts a new value constructed from x in the container. |
| 1819 | //! p is a hint pointing to where the insert should start to search. |
| 1820 | //! |
| 1821 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1822 | //! to the key of x. |
| 1823 | //! |
| 1824 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1825 | //! is inserted right before p. |
| 1826 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, const nonconst_value_type& x) |
| 1827 | { return this->base_t::emplace_hint_equal(p, x); } |
| 1828 | |
| 1829 | //! <b>Effects</b>: Inserts a new value move constructed from x in the container. |
| 1830 | //! p is a hint pointing to where the insert should start to search. |
| 1831 | //! |
| 1832 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1833 | //! to the key of x. |
| 1834 | //! |
| 1835 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1836 | //! is inserted right before p. |
| 1837 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) |
| 1838 | { return this->base_t::emplace_hint_equal(p, boost::move(x)); } |
| 1839 | |
| 1840 | //! <b>Effects</b>: Inserts a new value move constructed from x in the container. |
| 1841 | //! p is a hint pointing to where the insert should start to search. |
| 1842 | //! |
| 1843 | //! <b>Returns</b>: An iterator pointing to the element with key equivalent |
| 1844 | //! to the key of x. |
| 1845 | //! |
| 1846 | //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t |
| 1847 | //! is inserted right before p. |
| 1848 | BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) |
| 1849 | { return this->base_t::emplace_hint_equal(p, boost::move(x)); } |
| 1850 | |
| 1851 | //! <b>Requires</b>: first, last are not iterators into *this. |
| 1852 | //! |
| 1853 | //! <b>Effects</b>: inserts each element from the range [first,last) . |
| 1854 | //! |
| 1855 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last) |
| 1856 | template <class InputIterator> |
| 1857 | BOOST_CONTAINER_FORCEINLINE void insert(InputIterator first, InputIterator last) |
| 1858 | { this->base_t::insert_equal(first, last); } |
| 1859 | |
| 1860 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 1861 | //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end(). |
| 1862 | //! |
| 1863 | //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end()) |
| 1864 | BOOST_CONTAINER_FORCEINLINE void insert(std::initializer_list<value_type> il) |
| 1865 | { this->base_t::insert_equal(il.begin(), il.end()); } |
| 1866 | #endif |
| 1867 | |
| 1868 | //! <b>Requires</b>: nh is empty or this->get_allocator() == nh.get_allocator(). |
| 1869 | //! |
| 1870 | //! <b>Effects/Returns</b>: If nh is empty, has no effect and returns end(). Otherwise, inserts |
| 1871 | //! the element owned by nh and returns an iterator pointing to the newly inserted element. |
| 1872 | //! If a range containing elements with keys equivalent to nh.key() exists, |
| 1873 | //! the element is inserted at the end of that range. nh is always emptied. |
| 1874 | //! |
| 1875 | //! <b>Complexity</b>: Logarithmic |
| 1876 | iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 1877 | { |
| 1878 | typename base_t::node_type n(boost::move(nh)); |
| 1879 | return this->base_t::insert_equal_node(boost::move(n)); |
| 1880 | } |
| 1881 | |
| 1882 | //! <b>Effects</b>: Same as `insert(node_type && nh)` but the element is inserted as close as possible |
| 1883 | //! to the position just prior to "hint". |
| 1884 | //! |
| 1885 | //! <b>Complexity</b>: logarithmic in general, but amortized constant if the element is inserted |
| 1886 | //! right before "hint". |
| 1887 | iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh) |
| 1888 | { |
| 1889 | typename base_t::node_type n(boost::move(nh)); |
| 1890 | return this->base_t::insert_equal_node(hint, boost::move(n)); |
| 1891 | } |
| 1892 | |
| 1893 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1894 | |
| 1895 | //! @copydoc ::boost::container::set::erase(const_iterator) |
| 1896 | iterator erase(const_iterator p); |
| 1897 | |
| 1898 | //! @copydoc ::boost::container::set::erase(const key_type&) |
| 1899 | size_type erase(const key_type& x); |
| 1900 | |
| 1901 | //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator) |
| 1902 | iterator erase(const_iterator first, const_iterator last); |
| 1903 | #endif |
| 1904 | |
| 1905 | //! @copydoc ::boost::container::map::extract(const key_type&) |
| 1906 | node_type extract(const key_type& k) |
| 1907 | { |
| 1908 | typename base_t::node_type base_nh(this->base_t::extract(k)); |
| 1909 | return node_type(boost::move(base_nh)); |
| 1910 | } |
| 1911 | |
| 1912 | //! @copydoc ::boost::container::map::extract(const_iterator) |
| 1913 | node_type extract(const_iterator position) |
| 1914 | { |
| 1915 | typename base_t::node_type base_nh(this->base_t::extract(position)); |
| 1916 | return node_type (boost::move(base_nh)); |
| 1917 | } |
| 1918 | |
| 1919 | //! <b>Requires</b>: this->get_allocator() == source.get_allocator(). |
| 1920 | //! |
| 1921 | //! <b>Effects</b>: Extracts each element in source and insert it into a using |
| 1922 | //! the comparison object of *this. |
| 1923 | //! |
| 1924 | //! <b>Postcondition</b>: Pointers and references to the transferred elements of source refer |
| 1925 | //! to those same elements but as members of *this. Iterators referring to the transferred |
| 1926 | //! elements will continue to refer to their elements, but they now behave as iterators into *this, |
| 1927 | //! not into source. |
| 1928 | //! |
| 1929 | //! <b>Throws</b>: Nothing unless the comparison object throws. |
| 1930 | //! |
| 1931 | //! <b>Complexity</b>: N log(a.size() + N) (N has the value source.size()) |
| 1932 | template<class C2> |
| 1933 | BOOST_CONTAINER_FORCEINLINE void merge(multimap<Key, T, C2, Allocator, Options>& source) |
| 1934 | { |
| 1935 | typedef dtl::tree |
| 1936 | <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t; |
| 1937 | this->base_t::merge_equal(static_cast<base2_t&>(source)); |
| 1938 | } |
| 1939 | |
| 1940 | //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&) |
| 1941 | template<class C2> |
| 1942 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG multimap<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1943 | { return this->merge(static_cast<multimap<Key, T, C2, Allocator, Options>&>(source)); } |
| 1944 | |
| 1945 | //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&) |
| 1946 | template<class C2> |
| 1947 | BOOST_CONTAINER_FORCEINLINE void merge(map<Key, T, C2, Allocator, Options>& source) |
| 1948 | { |
| 1949 | typedef dtl::tree |
| 1950 | <value_type_impl, select_1st_t, C2, Allocator, Options> base2_t; |
| 1951 | this->base_t::merge_equal(static_cast<base2_t&>(source)); |
| 1952 | } |
| 1953 | |
| 1954 | //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&) |
| 1955 | template<class C2> |
| 1956 | BOOST_CONTAINER_FORCEINLINE void merge(BOOST_RV_REF_BEG map<Key, T, C2, Allocator, Options> BOOST_RV_REF_END source) |
| 1957 | { return this->merge(static_cast<map<Key, T, C2, Allocator, Options>&>(source)); } |
| 1958 | |
| 1959 | #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 1960 | //! @copydoc ::boost::container::set::swap |
| 1961 | void swap(multiset& x) |
| 1962 | BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value |
| 1963 | && boost::container::dtl::is_nothrow_swappable<Compare>::value ); |
| 1964 | |
| 1965 | //! @copydoc ::boost::container::set::clear |
| 1966 | void clear() BOOST_NOEXCEPT_OR_NOTHROW; |
| 1967 | |
| 1968 | //! @copydoc ::boost::container::set::key_comp |
| 1969 | key_compare key_comp() const; |
| 1970 | |
| 1971 | //! @copydoc ::boost::container::set::value_comp |
| 1972 | value_compare value_comp() const; |
| 1973 | |
| 1974 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 1975 | //! equivalent to x, or end() if such an element is not found. |
| 1976 | //! |
| 1977 | //! <b>Complexity</b>: Logarithmic. |
| 1978 | iterator find(const key_type& x); |
| 1979 | |
| 1980 | //! <b>Returns</b>: A const iterator pointing to an element with the key |
| 1981 | //! equivalent to x, or end() if such an element is not found. |
| 1982 | //! |
| 1983 | //! <b>Complexity</b>: Logarithmic. |
| 1984 | const_iterator find(const key_type& x) const; |
| 1985 | |
| 1986 | //! <b>Requires</b>: This overload is available only if |
| 1987 | //! key_compare::is_transparent exists. |
| 1988 | //! |
| 1989 | //! <b>Returns</b>: An iterator pointing to an element with the key |
| 1990 | //! equivalent to x, or end() if such an element is not found. |
| 1991 | //! |
| 1992 | //! <b>Complexity</b>: Logarithmic. |
| 1993 | template<typename K> |
| 1994 | iterator find(const K& x); |
| 1995 | |
| 1996 | //! <b>Requires</b>: This overload is available only if |
| 1997 | //! key_compare::is_transparent exists. |
| 1998 | //! |
| 1999 | //! <b>Returns</b>: A const_iterator pointing to an element with the key |
| 2000 | //! equivalent to x, or end() if such an element is not found. |
| 2001 | //! |
| 2002 | //! <b>Complexity</b>: Logarithmic. |
| 2003 | template<typename K> |
| 2004 | const_iterator find(const K& x) const; |
| 2005 | |
| 2006 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 2007 | //! |
| 2008 | //! <b>Complexity</b>: log(size())+count(k) |
| 2009 | size_type count(const key_type& x) const; |
| 2010 | |
| 2011 | //! <b>Requires</b>: This overload is available only if |
| 2012 | //! key_compare::is_transparent exists. |
| 2013 | //! |
| 2014 | //! <b>Returns</b>: The number of elements with key equivalent to x. |
| 2015 | //! |
| 2016 | //! <b>Complexity</b>: log(size())+count(k) |
| 2017 | template<typename K> |
| 2018 | size_type count(const K& x) const; |
| 2019 | |
| 2020 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 2021 | //! than k, or a.end() if such an element is not found. |
| 2022 | //! |
| 2023 | //! <b>Complexity</b>: Logarithmic |
| 2024 | iterator lower_bound(const key_type& x); |
| 2025 | |
| 2026 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 2027 | //! less than k, or a.end() if such an element is not found. |
| 2028 | //! |
| 2029 | //! <b>Complexity</b>: Logarithmic |
| 2030 | const_iterator lower_bound(const key_type& x) const; |
| 2031 | |
| 2032 | //! <b>Requires</b>: This overload is available only if |
| 2033 | //! key_compare::is_transparent exists. |
| 2034 | //! |
| 2035 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 2036 | //! than k, or a.end() if such an element is not found. |
| 2037 | //! |
| 2038 | //! <b>Complexity</b>: Logarithmic |
| 2039 | template<typename K> |
| 2040 | iterator lower_bound(const K& x); |
| 2041 | |
| 2042 | //! <b>Requires</b>: This overload is available only if |
| 2043 | //! key_compare::is_transparent exists. |
| 2044 | //! |
| 2045 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 2046 | //! less than k, or a.end() if such an element is not found. |
| 2047 | //! |
| 2048 | //! <b>Complexity</b>: Logarithmic |
| 2049 | template<typename K> |
| 2050 | const_iterator lower_bound(const K& x) const; |
| 2051 | |
| 2052 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 2053 | //! than x, or end() if such an element is not found. |
| 2054 | //! |
| 2055 | //! <b>Complexity</b>: Logarithmic |
| 2056 | iterator upper_bound(const key_type& x); |
| 2057 | |
| 2058 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 2059 | //! less than x, or end() if such an element is not found. |
| 2060 | //! |
| 2061 | //! <b>Complexity</b>: Logarithmic |
| 2062 | const_iterator upper_bound(const key_type& x) const; |
| 2063 | |
| 2064 | //! <b>Requires</b>: This overload is available only if |
| 2065 | //! key_compare::is_transparent exists. |
| 2066 | //! |
| 2067 | //! <b>Returns</b>: An iterator pointing to the first element with key not less |
| 2068 | //! than x, or end() if such an element is not found. |
| 2069 | //! |
| 2070 | //! <b>Complexity</b>: Logarithmic |
| 2071 | template<typename K> |
| 2072 | iterator upper_bound(const K& x); |
| 2073 | |
| 2074 | //! <b>Requires</b>: This overload is available only if |
| 2075 | //! key_compare::is_transparent exists. |
| 2076 | //! |
| 2077 | //! <b>Returns</b>: A const iterator pointing to the first element with key not |
| 2078 | //! less than x, or end() if such an element is not found. |
| 2079 | //! |
| 2080 | //! <b>Complexity</b>: Logarithmic |
| 2081 | template<typename K> |
| 2082 | const_iterator upper_bound(const K& x) const; |
| 2083 | |
| 2084 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 2085 | //! |
| 2086 | //! <b>Complexity</b>: Logarithmic |
| 2087 | std::pair<iterator,iterator> equal_range(const key_type& x); |
| 2088 | |
| 2089 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 2090 | //! |
| 2091 | //! <b>Complexity</b>: Logarithmic |
| 2092 | std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const; |
| 2093 | |
| 2094 | //! <b>Requires</b>: This overload is available only if |
| 2095 | //! key_compare::is_transparent exists. |
| 2096 | //! |
| 2097 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 2098 | //! |
| 2099 | //! <b>Complexity</b>: Logarithmic |
| 2100 | template<typename K> |
| 2101 | std::pair<iterator,iterator> equal_range(const K& x); |
| 2102 | |
| 2103 | //! <b>Requires</b>: This overload is available only if |
| 2104 | //! key_compare::is_transparent exists. |
| 2105 | //! |
| 2106 | //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). |
| 2107 | //! |
| 2108 | //! <b>Complexity</b>: Logarithmic |
| 2109 | template<typename K> |
| 2110 | std::pair<const_iterator,const_iterator> equal_range(const K& x) const; |
| 2111 | |
| 2112 | //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees. |
| 2113 | //! |
| 2114 | //! <b>Complexity</b>: Linear |
| 2115 | void rebalance(); |
| 2116 | |
| 2117 | //! <b>Effects</b>: Returns true if x and y are equal |
| 2118 | //! |
| 2119 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2120 | friend bool operator==(const multimap& x, const multimap& y); |
| 2121 | |
| 2122 | //! <b>Effects</b>: Returns true if x and y are unequal |
| 2123 | //! |
| 2124 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2125 | friend bool operator!=(const multimap& x, const multimap& y); |
| 2126 | |
| 2127 | //! <b>Effects</b>: Returns true if x is less than y |
| 2128 | //! |
| 2129 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2130 | friend bool operator<(const multimap& x, const multimap& y); |
| 2131 | |
| 2132 | //! <b>Effects</b>: Returns true if x is greater than y |
| 2133 | //! |
| 2134 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2135 | friend bool operator>(const multimap& x, const multimap& y); |
| 2136 | |
| 2137 | //! <b>Effects</b>: Returns true if x is equal or less than y |
| 2138 | //! |
| 2139 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2140 | friend bool operator<=(const multimap& x, const multimap& y); |
| 2141 | |
| 2142 | //! <b>Effects</b>: Returns true if x is equal or greater than y |
| 2143 | //! |
| 2144 | //! <b>Complexity</b>: Linear to the number of elements in the container. |
| 2145 | friend bool operator>=(const multimap& x, const multimap& y); |
| 2146 | |
| 2147 | //! <b>Effects</b>: x.swap(y) |
| 2148 | //! |
| 2149 | //! <b>Complexity</b>: Constant. |
| 2150 | friend void swap(multimap& x, multimap& y); |
| 2151 | |
| 2152 | #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
| 2153 | }; |
| 2154 | |
| 2155 | #if __cplusplus >= 201703L |
| 2156 | |
| 2157 | template <typename InputIterator> |
| 2158 | multimap(InputIterator, InputIterator) -> |
| 2159 | multimap<typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2160 | , typename iterator_traits<InputIterator>::value_type::second_type>; |
| 2161 | |
| 2162 | template <typename InputIterator, typename Allocator> |
| 2163 | multimap(InputIterator, InputIterator, Allocator const&) -> |
| 2164 | multimap<typename dtl::remove_const< typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2165 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2166 | , std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type> |
| 2167 | , Allocator>; |
| 2168 | |
| 2169 | template <typename InputIterator, typename Compare> |
| 2170 | multimap(InputIterator, InputIterator, Compare const&) -> |
| 2171 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2172 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2173 | , Compare>; |
| 2174 | |
| 2175 | template <typename InputIterator, typename Compare, typename Allocator> |
| 2176 | multimap(InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 2177 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2178 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2179 | , Compare |
| 2180 | , Allocator>; |
| 2181 | |
| 2182 | template <typename InputIterator> |
| 2183 | multimap(ordered_range_t, InputIterator, InputIterator) -> |
| 2184 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2185 | , typename iterator_traits<InputIterator>::value_type::second_type>; |
| 2186 | |
| 2187 | template <typename InputIterator, typename Allocator> |
| 2188 | multimap(ordered_range_t, InputIterator, InputIterator, Allocator const&) -> |
| 2189 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2190 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2191 | , std::less<typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type> |
| 2192 | , Allocator>; |
| 2193 | |
| 2194 | template <typename InputIterator, typename Compare> |
| 2195 | multimap(ordered_range_t, InputIterator, InputIterator, Compare const&) -> |
| 2196 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2197 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2198 | , Compare>; |
| 2199 | |
| 2200 | template <typename InputIterator, typename Compare, typename Allocator> |
| 2201 | multimap(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) -> |
| 2202 | multimap< typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type |
| 2203 | , typename iterator_traits<InputIterator>::value_type::second_type |
| 2204 | , Compare |
| 2205 | , Allocator>; |
| 2206 | |
| 2207 | #endif |
| 2208 | |
| 2209 | #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 2210 | |
| 2211 | } //namespace container { |
| 2212 | |
| 2213 | //!has_trivial_destructor_after_move<> == true_type |
| 2214 | //!specialization for optimizations |
| 2215 | template <class Key, class T, class Compare, class Allocator> |
| 2216 | struct has_trivial_destructor_after_move<boost::container::multimap<Key, T, Compare, Allocator> > |
| 2217 | { |
| 2218 | typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer; |
| 2219 | static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value && |
| 2220 | ::boost::has_trivial_destructor_after_move<pointer>::value && |
| 2221 | ::boost::has_trivial_destructor_after_move<Compare>::value; |
| 2222 | }; |
| 2223 | |
| 2224 | namespace container { |
| 2225 | |
| 2226 | #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED |
| 2227 | |
| 2228 | }} |
| 2229 | |
| 2230 | #include <boost/container/detail/config_end.hpp> |
| 2231 | |
| 2232 | #endif // BOOST_CONTAINER_MAP_HPP |
| 2233 | |