annotate DEPENDENCIES/generic/include/boost/container/map.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@101 3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 //
Chris@16 7 // See http://www.boost.org/libs/container for documentation.
Chris@16 8 //
Chris@16 9 //////////////////////////////////////////////////////////////////////////////
Chris@16 10 #ifndef BOOST_CONTAINER_MAP_HPP
Chris@16 11 #define BOOST_CONTAINER_MAP_HPP
Chris@16 12
Chris@101 13 #ifndef BOOST_CONFIG_HPP
Chris@101 14 # include <boost/config.hpp>
Chris@101 15 #endif
Chris@101 16
Chris@101 17 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@16 18 # pragma once
Chris@16 19 #endif
Chris@16 20
Chris@16 21 #include <boost/container/detail/config_begin.hpp>
Chris@16 22 #include <boost/container/detail/workaround.hpp>
Chris@16 23
Chris@101 24 // container
Chris@16 25 #include <boost/container/container_fwd.hpp>
Chris@101 26 #include <boost/container/new_allocator.hpp> //new_allocator
Chris@101 27 #include <boost/container/throw_exception.hpp>
Chris@101 28 // container/detail
Chris@101 29 #include <boost/container/detail/mpl.hpp>
Chris@16 30 #include <boost/container/detail/tree.hpp>
Chris@101 31 #include <boost/container/detail/type_traits.hpp>
Chris@16 32 #include <boost/container/detail/value_init.hpp>
Chris@16 33 #include <boost/container/detail/pair.hpp>
Chris@101 34 // move
Chris@101 35 #include <boost/move/traits.hpp>
Chris@101 36 #include <boost/move/utility_core.hpp>
Chris@101 37 // move/detail
Chris@101 38 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@101 39 #include <boost/move/detail/fwd_macros.hpp>
Chris@101 40 #endif
Chris@16 41 #include <boost/move/detail/move_helpers.hpp>
Chris@101 42 // intrusive/detail
Chris@101 43 #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
Chris@101 44 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
Chris@101 45 // other
Chris@16 46 #include <boost/static_assert.hpp>
Chris@101 47 #include <boost/core/no_exceptions_support.hpp>
Chris@101 48 // std
Chris@101 49 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 50 #include <initializer_list>
Chris@101 51 #endif
Chris@16 52
Chris@16 53 namespace boost {
Chris@16 54 namespace container {
Chris@16 55
Chris@101 56 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 57
Chris@16 58 //! A map is a kind of associative container that supports unique keys (contains at
Chris@16 59 //! most one of each key value) and provides for fast retrieval of values of another
Chris@16 60 //! type T based on the keys. The map class supports bidirectional iterators.
Chris@16 61 //!
Chris@16 62 //! A map satisfies all of the requirements of a container and of a reversible
Chris@101 63 //! container and of an associative container. The <code>value_type</code> stored
Chris@101 64 //! by this container is the value_type is std::pair<const Key, T>.
Chris@16 65 //!
Chris@101 66 //! \tparam Key is the key_type of the map
Chris@101 67 //! \tparam T is the <code>mapped_type</code>
Chris@101 68 //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
Chris@101 69 //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
Chris@101 70 //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
Chris@101 71 //! \tparam MapOptions is an packed option type generated using using boost::container::tree_assoc_options.
Chris@101 72 template < class Key, class T, class Compare = std::less<Key>
Chris@101 73 , class Allocator = new_allocator< std::pair< const Key, T> >, class MapOptions = tree_assoc_defaults >
Chris@16 74 #else
Chris@101 75 template <class Key, class T, class Compare, class Allocator, class MapOptions>
Chris@16 76 #endif
Chris@16 77 class map
Chris@101 78 ///@cond
Chris@101 79 : public container_detail::tree
Chris@101 80 < Key, std::pair<const Key, T>
Chris@101 81 , container_detail::select1st< std::pair<const Key, T> >
Chris@101 82 , Compare, Allocator, MapOptions>
Chris@101 83 ///@endcond
Chris@16 84 {
Chris@101 85 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 86 private:
Chris@16 87 BOOST_COPYABLE_AND_MOVABLE(map)
Chris@16 88
Chris@16 89 typedef std::pair<const Key, T> value_type_impl;
Chris@101 90 typedef container_detail::tree
Chris@101 91 <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator, MapOptions> base_t;
Chris@16 92 typedef container_detail::pair <Key, T> movable_value_type_impl;
Chris@16 93 typedef container_detail::tree_value_compare
Chris@16 94 < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
Chris@16 95 > value_compare_impl;
Chris@101 96 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 97
Chris@16 98 public:
Chris@16 99 //////////////////////////////////////////////
Chris@16 100 //
Chris@16 101 // types
Chris@16 102 //
Chris@16 103 //////////////////////////////////////////////
Chris@16 104
Chris@101 105 typedef Key key_type;
Chris@101 106 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
Chris@101 107 typedef T mapped_type;
Chris@101 108 typedef std::pair<const Key, T> value_type;
Chris@16 109 typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@16 110 typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
Chris@16 111 typedef typename boost::container::allocator_traits<Allocator>::reference reference;
Chris@16 112 typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
Chris@16 113 typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
Chris@16 114 typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
Chris@16 115 typedef Allocator allocator_type;
Chris@101 116 typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
Chris@16 117 typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
Chris@16 118 typedef Compare key_compare;
Chris@101 119 typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
Chris@101 120 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
Chris@101 121 typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
Chris@101 122 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
Chris@16 123 typedef std::pair<key_type, mapped_type> nonconst_value_type;
Chris@16 124 typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
Chris@16 125
Chris@16 126 //////////////////////////////////////////////
Chris@16 127 //
Chris@16 128 // construct/copy/destroy
Chris@16 129 //
Chris@16 130 //////////////////////////////////////////////
Chris@16 131
Chris@16 132 //! <b>Effects</b>: Default constructs an empty map.
Chris@16 133 //!
Chris@16 134 //! <b>Complexity</b>: Constant.
Chris@16 135 map()
Chris@101 136 : base_t()
Chris@16 137 {
Chris@101 138 //A type must be std::pair<CONST Key, T>
Chris@16 139 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 140 }
Chris@16 141
Chris@16 142 //! <b>Effects</b>: Constructs an empty map using the specified comparison object
Chris@16 143 //! and allocator.
Chris@16 144 //!
Chris@16 145 //! <b>Complexity</b>: Constant.
Chris@101 146 explicit map(const Compare& comp, const allocator_type& a = allocator_type())
Chris@101 147 : base_t(comp, a)
Chris@16 148 {
Chris@101 149 //A type must be std::pair<CONST Key, T>
Chris@16 150 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 151 }
Chris@16 152
Chris@16 153 //! <b>Effects</b>: Constructs an empty map using the specified allocator.
Chris@16 154 //!
Chris@16 155 //! <b>Complexity</b>: Constant.
Chris@16 156 explicit map(const allocator_type& a)
Chris@101 157 : base_t(a)
Chris@16 158 {
Chris@101 159 //A type must be std::pair<CONST Key, T>
Chris@16 160 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 161 }
Chris@16 162
Chris@16 163 //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
Chris@16 164 //! allocator, and inserts elements from the range [first ,last ).
Chris@16 165 //!
Chris@16 166 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@16 167 //! comp and otherwise N logN, where N is last - first.
Chris@16 168 template <class InputIterator>
Chris@16 169 map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
Chris@16 170 const allocator_type& a = allocator_type())
Chris@101 171 : base_t(true, first, last, comp, a)
Chris@16 172 {
Chris@101 173 //A type must be std::pair<CONST Key, T>
Chris@101 174 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 175 }
Chris@101 176
Chris@101 177 //! <b>Effects</b>: Constructs an empty map using the specified
Chris@101 178 //! allocator, and inserts elements from the range [first ,last ).
Chris@101 179 //!
Chris@101 180 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 181 //! comp and otherwise N logN, where N is last - first.
Chris@101 182 template <class InputIterator>
Chris@101 183 map(InputIterator first, InputIterator last, const allocator_type& a)
Chris@101 184 : base_t(true, first, last, Compare(), a)
Chris@101 185 {
Chris@101 186 //A type must be std::pair<CONST Key, T>
Chris@16 187 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 188 }
Chris@16 189
Chris@16 190 //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
Chris@16 191 //! allocator, and inserts elements from the ordered unique range [first ,last). This function
Chris@16 192 //! is more efficient than the normal range creation for ordered ranges.
Chris@16 193 //!
Chris@16 194 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
Chris@16 195 //! unique values.
Chris@16 196 //!
Chris@16 197 //! <b>Complexity</b>: Linear in N.
Chris@16 198 //!
Chris@16 199 //! <b>Note</b>: Non-standard extension.
Chris@16 200 template <class InputIterator>
Chris@16 201 map( ordered_unique_range_t, InputIterator first, InputIterator last
Chris@16 202 , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 203 : base_t(ordered_range, first, last, comp, a)
Chris@16 204 {
Chris@101 205 //A type must be std::pair<CONST Key, T>
Chris@16 206 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 207 }
Chris@16 208
Chris@101 209 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 210 //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
Chris@101 211 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 212 //!
Chris@101 213 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 214 //! comp and otherwise N logN, where N is il.first() - il.end().
Chris@101 215 map(std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a = allocator_type())
Chris@101 216 : base_t(true, il.begin(), il.end(), comp, a)
Chris@101 217 {
Chris@101 218 //A type must be std::pair<CONST Key, T>
Chris@101 219 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 220 }
Chris@101 221
Chris@101 222 //! <b>Effects</b>: Constructs an empty map using the specified
Chris@101 223 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 224 //!
Chris@101 225 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 226 //! comp and otherwise N logN, where N is il.first() - il.end().
Chris@101 227 map(std::initializer_list<value_type> il, const allocator_type& a)
Chris@101 228 : base_t(true, il.begin(), il.end(), Compare(), a)
Chris@101 229 {
Chris@101 230 //A type must be std::pair<CONST Key, T>
Chris@101 231 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 232 }
Chris@101 233
Chris@101 234 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@101 235 //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
Chris@101 236 //! is more efficient than the normal range creation for ordered ranges.
Chris@101 237 //!
Chris@101 238 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
Chris@101 239 //! unique values.
Chris@101 240 //!
Chris@101 241 //! <b>Complexity</b>: Linear in N.
Chris@101 242 //!
Chris@101 243 //! <b>Note</b>: Non-standard extension.
Chris@101 244 map(ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp = Compare(),
Chris@101 245 const allocator_type& a = allocator_type())
Chris@101 246 : base_t(ordered_range, il.begin(), il.end(), comp, a)
Chris@101 247 {
Chris@101 248 //A type must be std::pair<CONST Key, T>
Chris@101 249 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 250 }
Chris@101 251 #endif
Chris@101 252
Chris@16 253 //! <b>Effects</b>: Copy constructs a map.
Chris@16 254 //!
Chris@16 255 //! <b>Complexity</b>: Linear in x.size().
Chris@16 256 map(const map& x)
Chris@101 257 : base_t(static_cast<const base_t&>(x))
Chris@16 258 {
Chris@101 259 //A type must be std::pair<CONST Key, T>
Chris@16 260 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 261 }
Chris@16 262
Chris@16 263 //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
Chris@16 264 //!
Chris@16 265 //! <b>Complexity</b>: Constant.
Chris@16 266 //!
Chris@16 267 //! <b>Postcondition</b>: x is emptied.
Chris@16 268 map(BOOST_RV_REF(map) x)
Chris@101 269 : base_t(BOOST_MOVE_BASE(base_t, x))
Chris@16 270 {
Chris@101 271 //A type must be std::pair<CONST Key, T>
Chris@16 272 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 273 }
Chris@16 274
Chris@16 275 //! <b>Effects</b>: Copy constructs a map using the specified allocator.
Chris@16 276 //!
Chris@16 277 //! <b>Complexity</b>: Linear in x.size().
Chris@16 278 map(const map& x, const allocator_type &a)
Chris@101 279 : base_t(static_cast<const base_t&>(x), a)
Chris@16 280 {
Chris@101 281 //A type must be std::pair<CONST Key, T>
Chris@16 282 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 283 }
Chris@16 284
Chris@16 285 //! <b>Effects</b>: Move constructs a map using the specified allocator.
Chris@16 286 //! Constructs *this using x's resources.
Chris@16 287 //!
Chris@16 288 //! <b>Complexity</b>: Constant if x == x.get_allocator(), linear otherwise.
Chris@16 289 //!
Chris@16 290 //! <b>Postcondition</b>: x is emptied.
Chris@16 291 map(BOOST_RV_REF(map) x, const allocator_type &a)
Chris@101 292 : base_t(BOOST_MOVE_BASE(base_t, x), a)
Chris@16 293 {
Chris@101 294 //A type must be std::pair<CONST Key, T>
Chris@16 295 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 296 }
Chris@16 297
Chris@16 298 //! <b>Effects</b>: Makes *this a copy of x.
Chris@16 299 //!
Chris@16 300 //! <b>Complexity</b>: Linear in x.size().
Chris@16 301 map& operator=(BOOST_COPY_ASSIGN_REF(map) x)
Chris@101 302 { return static_cast<map&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
Chris@16 303
Chris@16 304 //! <b>Effects</b>: this->swap(x.get()).
Chris@16 305 //!
Chris@101 306 //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
Chris@101 307 //! is false and (allocation throws or value_type's move constructor throws)
Chris@101 308 //!
Chris@101 309 //! <b>Complexity</b>: Constant if allocator_traits_type::
Chris@101 310 //! propagate_on_container_move_assignment is true or
Chris@101 311 //! this->get>allocator() == x.get_allocator(). Linear otherwise.
Chris@16 312 map& operator=(BOOST_RV_REF(map) x)
Chris@101 313 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 314 && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
Chris@16 315
Chris@101 316 { return static_cast<map&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
Chris@101 317
Chris@101 318 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 319 //! <b>Effects</b>: Assign content of il to *this.
Chris@101 320 //!
Chris@101 321 map& operator=(std::initializer_list<value_type> il)
Chris@101 322 {
Chris@101 323 this->clear();
Chris@101 324 insert(il.begin(), il.end());
Chris@101 325 return *this;
Chris@101 326 }
Chris@101 327 #endif
Chris@101 328
Chris@101 329 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 330
Chris@101 331 //! <b>Effects</b>: Returns a copy of the allocator that
Chris@16 332 //! was passed to the object's constructor.
Chris@16 333 //!
Chris@16 334 //! <b>Complexity</b>: Constant.
Chris@101 335 allocator_type get_allocator() const;
Chris@16 336
Chris@16 337 //! <b>Effects</b>: Returns a reference to the internal allocator.
Chris@16 338 //!
Chris@16 339 //! <b>Throws</b>: Nothing
Chris@16 340 //!
Chris@16 341 //! <b>Complexity</b>: Constant.
Chris@16 342 //!
Chris@16 343 //! <b>Note</b>: Non-standard extension.
Chris@101 344 stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 345
Chris@16 346 //! <b>Effects</b>: Returns a reference to the internal allocator.
Chris@16 347 //!
Chris@16 348 //! <b>Throws</b>: Nothing
Chris@16 349 //!
Chris@16 350 //! <b>Complexity</b>: Constant.
Chris@16 351 //!
Chris@16 352 //! <b>Note</b>: Non-standard extension.
Chris@101 353 const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 354
Chris@16 355 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
Chris@16 356 //!
Chris@16 357 //! <b>Throws</b>: Nothing.
Chris@16 358 //!
Chris@16 359 //! <b>Complexity</b>: Constant.
Chris@101 360 iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 361
Chris@16 362 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
Chris@16 363 //!
Chris@16 364 //! <b>Throws</b>: Nothing.
Chris@16 365 //!
Chris@16 366 //! <b>Complexity</b>: Constant.
Chris@101 367 const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@101 368
Chris@101 369 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
Chris@101 370 //!
Chris@101 371 //! <b>Throws</b>: Nothing.
Chris@101 372 //!
Chris@101 373 //! <b>Complexity</b>: Constant.
Chris@101 374 const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 375
Chris@16 376 //! <b>Effects</b>: Returns an iterator to the end of the container.
Chris@16 377 //!
Chris@16 378 //! <b>Throws</b>: Nothing.
Chris@16 379 //!
Chris@16 380 //! <b>Complexity</b>: Constant.
Chris@101 381 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 382
Chris@16 383 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
Chris@16 384 //!
Chris@16 385 //! <b>Throws</b>: Nothing.
Chris@16 386 //!
Chris@16 387 //! <b>Complexity</b>: Constant.
Chris@101 388 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@101 389
Chris@101 390 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
Chris@101 391 //!
Chris@101 392 //! <b>Throws</b>: Nothing.
Chris@101 393 //!
Chris@101 394 //! <b>Complexity</b>: Constant.
Chris@101 395 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 396
Chris@16 397 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
Chris@16 398 //! of the reversed container.
Chris@16 399 //!
Chris@16 400 //! <b>Throws</b>: Nothing.
Chris@16 401 //!
Chris@16 402 //! <b>Complexity</b>: Constant.
Chris@101 403 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 404
Chris@16 405 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
Chris@16 406 //! of the reversed container.
Chris@16 407 //!
Chris@16 408 //! <b>Throws</b>: Nothing.
Chris@16 409 //!
Chris@16 410 //! <b>Complexity</b>: Constant.
Chris@101 411 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@101 412
Chris@101 413 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
Chris@101 414 //! of the reversed container.
Chris@101 415 //!
Chris@101 416 //! <b>Throws</b>: Nothing.
Chris@101 417 //!
Chris@101 418 //! <b>Complexity</b>: Constant.
Chris@101 419 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 420
Chris@16 421 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
Chris@16 422 //! of the reversed container.
Chris@16 423 //!
Chris@16 424 //! <b>Throws</b>: Nothing.
Chris@16 425 //!
Chris@16 426 //! <b>Complexity</b>: Constant.
Chris@101 427 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 428
Chris@16 429 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
Chris@16 430 //! of the reversed container.
Chris@16 431 //!
Chris@16 432 //! <b>Throws</b>: Nothing.
Chris@16 433 //!
Chris@16 434 //! <b>Complexity</b>: Constant.
Chris@101 435 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 436
Chris@16 437 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
Chris@16 438 //! of the reversed container.
Chris@16 439 //!
Chris@16 440 //! <b>Throws</b>: Nothing.
Chris@16 441 //!
Chris@16 442 //! <b>Complexity</b>: Constant.
Chris@101 443 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 444
Chris@16 445 //! <b>Effects</b>: Returns true if the container contains no elements.
Chris@16 446 //!
Chris@16 447 //! <b>Throws</b>: Nothing.
Chris@16 448 //!
Chris@16 449 //! <b>Complexity</b>: Constant.
Chris@101 450 bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 451
Chris@16 452 //! <b>Effects</b>: Returns the number of the elements contained in the container.
Chris@16 453 //!
Chris@16 454 //! <b>Throws</b>: Nothing.
Chris@16 455 //!
Chris@16 456 //! <b>Complexity</b>: Constant.
Chris@101 457 size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 458
Chris@16 459 //! <b>Effects</b>: Returns the largest possible size of the container.
Chris@16 460 //!
Chris@16 461 //! <b>Throws</b>: Nothing.
Chris@16 462 //!
Chris@16 463 //! <b>Complexity</b>: Constant.
Chris@101 464 size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 465
Chris@101 466 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 467
Chris@16 468 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 469 //! Effects: If there is no key equivalent to x in the map, inserts
Chris@16 470 //! value_type(x, T()) into the map.
Chris@16 471 //!
Chris@101 472 //! Returns: A reference to the mapped_type corresponding to x in *this.
Chris@16 473 //!
Chris@16 474 //! Complexity: Logarithmic.
Chris@16 475 mapped_type& operator[](const key_type &k);
Chris@16 476
Chris@16 477 //! Effects: If there is no key equivalent to x in the map, inserts
Chris@16 478 //! value_type(boost::move(x), T()) into the map (the key is move-constructed)
Chris@16 479 //!
Chris@101 480 //! Returns: A reference to the mapped_type corresponding to x in *this.
Chris@16 481 //!
Chris@16 482 //! Complexity: Logarithmic.
Chris@16 483 mapped_type& operator[](key_type &&k);
Chris@16 484 #else
Chris@16 485 BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
Chris@16 486 #endif
Chris@16 487
Chris@101 488 //! Returns: A reference to the element whose key is equivalent to x.
Chris@16 489 //! Throws: An exception object of type out_of_range if no such element is present.
Chris@16 490 //! Complexity: logarithmic.
Chris@16 491 T& at(const key_type& k)
Chris@16 492 {
Chris@16 493 iterator i = this->find(k);
Chris@16 494 if(i == this->end()){
Chris@16 495 throw_out_of_range("map::at key not found");
Chris@16 496 }
Chris@16 497 return i->second;
Chris@16 498 }
Chris@16 499
Chris@101 500 //! Returns: A reference to the element whose key is equivalent to x.
Chris@16 501 //! Throws: An exception object of type out_of_range if no such element is present.
Chris@16 502 //! Complexity: logarithmic.
Chris@16 503 const T& at(const key_type& k) const
Chris@16 504 {
Chris@16 505 const_iterator i = this->find(k);
Chris@16 506 if(i == this->end()){
Chris@16 507 throw_out_of_range("map::at key not found");
Chris@16 508 }
Chris@16 509 return i->second;
Chris@16 510 }
Chris@16 511
Chris@16 512 //////////////////////////////////////////////
Chris@16 513 //
Chris@16 514 // modifiers
Chris@16 515 //
Chris@16 516 //////////////////////////////////////////////
Chris@16 517
Chris@16 518 //! <b>Effects</b>: Inserts x if and only if there is no element in the container
Chris@16 519 //! with key equivalent to the key of x.
Chris@16 520 //!
Chris@16 521 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 522 //! if the insertion takes place, and the iterator component of the pair
Chris@16 523 //! points to the element with key equivalent to the key of x.
Chris@16 524 //!
Chris@16 525 //! <b>Complexity</b>: Logarithmic.
Chris@16 526 std::pair<iterator,bool> insert(const value_type& x)
Chris@101 527 { return this->base_t::insert_unique(x); }
Chris@16 528
Chris@16 529 //! <b>Effects</b>: Inserts a new value_type created from the pair if and only if
Chris@16 530 //! there is no element in the container with key equivalent to the key of x.
Chris@16 531 //!
Chris@16 532 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 533 //! if the insertion takes place, and the iterator component of the pair
Chris@16 534 //! points to the element with key equivalent to the key of x.
Chris@16 535 //!
Chris@16 536 //! <b>Complexity</b>: Logarithmic.
Chris@16 537 std::pair<iterator,bool> insert(const nonconst_value_type& x)
Chris@101 538 { return this->base_t::insert_unique(x); }
Chris@16 539
Chris@16 540 //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
Chris@16 541 //! only if there is no element in the container with key equivalent to the key of x.
Chris@16 542 //!
Chris@16 543 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 544 //! if the insertion takes place, and the iterator component of the pair
Chris@16 545 //! points to the element with key equivalent to the key of x.
Chris@16 546 //!
Chris@16 547 //! <b>Complexity</b>: Logarithmic.
Chris@16 548 std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
Chris@101 549 { return this->base_t::insert_unique(boost::move(x)); }
Chris@16 550
Chris@16 551 //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
Chris@16 552 //! only if there is no element in the container with key equivalent to the key of x.
Chris@16 553 //!
Chris@16 554 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 555 //! if the insertion takes place, and the iterator component of the pair
Chris@16 556 //! points to the element with key equivalent to the key of x.
Chris@16 557 //!
Chris@16 558 //! <b>Complexity</b>: Logarithmic.
Chris@16 559 std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
Chris@101 560 { return this->base_t::insert_unique(boost::move(x)); }
Chris@16 561
Chris@16 562 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
Chris@16 563 //! no element in the container with key equivalent to the key of x.
Chris@16 564 //!
Chris@16 565 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 566 //! if the insertion takes place, and the iterator component of the pair
Chris@16 567 //! points to the element with key equivalent to the key of x.
Chris@16 568 //!
Chris@16 569 //! <b>Complexity</b>: Logarithmic.
Chris@16 570 std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
Chris@101 571 { return this->base_t::insert_unique(boost::move(x)); }
Chris@16 572
Chris@16 573 //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
Chris@16 574 //! no element in the container with key equivalent to the key of x.
Chris@16 575 //! p is a hint pointing to where the insert should start to search.
Chris@16 576 //!
Chris@16 577 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 578 //! to the key of x.
Chris@16 579 //!
Chris@16 580 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 581 //! is inserted right before p.
Chris@101 582 iterator insert(const_iterator p, const value_type& x)
Chris@101 583 { return this->base_t::insert_unique(p, x); }
Chris@16 584
Chris@16 585 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
Chris@16 586 //! no element in the container with key equivalent to the key of x.
Chris@16 587 //! p is a hint pointing to where the insert should start to search.
Chris@16 588 //!
Chris@16 589 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 590 //! to the key of x.
Chris@16 591 //!
Chris@16 592 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 593 //! is inserted right before p.
Chris@101 594 iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x)
Chris@101 595 { return this->base_t::insert_unique(p, boost::move(x)); }
Chris@16 596
Chris@16 597 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
Chris@16 598 //! no element in the container with key equivalent to the key of x.
Chris@16 599 //! p is a hint pointing to where the insert should start to search.
Chris@16 600 //!
Chris@16 601 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 602 //! to the key of x.
Chris@16 603 //!
Chris@16 604 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 605 //! is inserted right before p.
Chris@101 606 iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x)
Chris@101 607 { return this->base_t::insert_unique(p, boost::move(x)); }
Chris@16 608
Chris@16 609 //! <b>Effects</b>: Inserts a copy of x in the container.
Chris@16 610 //! p is a hint pointing to where the insert should start to search.
Chris@16 611 //!
Chris@16 612 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
Chris@16 613 //!
Chris@16 614 //! <b>Complexity</b>: Logarithmic.
Chris@101 615 iterator insert(const_iterator p, const nonconst_value_type& x)
Chris@101 616 { return this->base_t::insert_unique(p, x); }
Chris@16 617
Chris@16 618 //! <b>Effects</b>: Inserts an element move constructed from x in the container.
Chris@16 619 //! p is a hint pointing to where the insert should start to search.
Chris@16 620 //!
Chris@16 621 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
Chris@16 622 //!
Chris@16 623 //! <b>Complexity</b>: Logarithmic.
Chris@101 624 iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
Chris@101 625 { return this->base_t::insert_unique(p, boost::move(x)); }
Chris@16 626
Chris@16 627 //! <b>Requires</b>: first, last are not iterators into *this.
Chris@16 628 //!
Chris@16 629 //! <b>Effects</b>: inserts each element from the range [first,last) if and only
Chris@16 630 //! if there is no element with key equivalent to the key of that element.
Chris@16 631 //!
Chris@16 632 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
Chris@16 633 template <class InputIterator>
Chris@16 634 void insert(InputIterator first, InputIterator last)
Chris@101 635 { this->base_t::insert_unique(first, last); }
Chris@16 636
Chris@101 637 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 638 //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end()) if and only
Chris@101 639 //! if there is no element with key equivalent to the key of that element.
Chris@101 640 //!
Chris@101 641 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
Chris@101 642 void insert(std::initializer_list<value_type> il)
Chris@101 643 { this->base_t::insert_unique(il.begin(), il.end()); }
Chris@101 644 #endif
Chris@101 645
Chris@101 646 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 647
Chris@16 648 //! <b>Effects</b>: Inserts an object x of type T constructed with
Chris@16 649 //! std::forward<Args>(args)... in the container if and only if there is
Chris@16 650 //! no element in the container with an equivalent key.
Chris@16 651 //! p is a hint pointing to where the insert should start to search.
Chris@16 652 //!
Chris@16 653 //! <b>Returns</b>: The bool component of the returned pair is true if and only
Chris@16 654 //! if the insertion takes place, and the iterator component of the pair
Chris@16 655 //! points to the element with key equivalent to the key of x.
Chris@16 656 //!
Chris@16 657 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 658 //! is inserted right before p.
Chris@16 659 template <class... Args>
Chris@101 660 std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
Chris@101 661 { return this->base_t::emplace_unique(boost::forward<Args>(args)...); }
Chris@16 662
Chris@16 663 //! <b>Effects</b>: Inserts an object of type T constructed with
Chris@16 664 //! std::forward<Args>(args)... in the container if and only if there is
Chris@16 665 //! no element in the container with an equivalent key.
Chris@16 666 //! p is a hint pointing to where the insert should start to search.
Chris@16 667 //!
Chris@16 668 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 669 //! to the key of x.
Chris@16 670 //!
Chris@16 671 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 672 //! is inserted right before p.
Chris@16 673 template <class... Args>
Chris@101 674 iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
Chris@101 675 { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
Chris@16 676
Chris@101 677 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 678
Chris@101 679 #define BOOST_CONTAINER_MAP_EMPLACE_CODE(N) \
Chris@101 680 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 681 std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
Chris@101 682 { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\
Chris@101 683 \
Chris@101 684 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 685 iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
Chris@101 686 { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
Chris@101 687 //
Chris@101 688 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MAP_EMPLACE_CODE)
Chris@101 689 #undef BOOST_CONTAINER_MAP_EMPLACE_CODE
Chris@16 690
Chris@101 691 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 692
Chris@101 693 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 694
Chris@101 695 //! <b>Effects</b>: Erases the element pointed to by p.
Chris@16 696 //!
Chris@16 697 //! <b>Returns</b>: Returns an iterator pointing to the element immediately
Chris@16 698 //! following q prior to the element being erased. If no such element exists,
Chris@16 699 //! returns end().
Chris@16 700 //!
Chris@16 701 //! <b>Complexity</b>: Amortized constant time
Chris@101 702 iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 703
Chris@16 704 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
Chris@16 705 //!
Chris@16 706 //! <b>Returns</b>: Returns the number of erased elements.
Chris@16 707 //!
Chris@16 708 //! <b>Complexity</b>: log(size()) + count(k)
Chris@101 709 size_type erase(const key_type& x) BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 710
Chris@16 711 //! <b>Effects</b>: Erases all the elements in the range [first, last).
Chris@16 712 //!
Chris@16 713 //! <b>Returns</b>: Returns last.
Chris@16 714 //!
Chris@16 715 //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
Chris@101 716 iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 717
Chris@16 718 //! <b>Effects</b>: Swaps the contents of *this and x.
Chris@16 719 //!
Chris@16 720 //! <b>Throws</b>: Nothing.
Chris@16 721 //!
Chris@16 722 //! <b>Complexity</b>: Constant.
Chris@16 723 void swap(map& x)
Chris@101 724 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 725 && boost::container::container_detail::is_nothrow_swappable<Compare>::value )
Chris@16 726
Chris@16 727 //! <b>Effects</b>: erase(a.begin(),a.end()).
Chris@16 728 //!
Chris@16 729 //! <b>Postcondition</b>: size() == 0.
Chris@16 730 //!
Chris@16 731 //! <b>Complexity</b>: linear in size().
Chris@101 732 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 733
Chris@16 734 //! <b>Effects</b>: Returns the comparison object out
Chris@16 735 //! of which a was constructed.
Chris@16 736 //!
Chris@16 737 //! <b>Complexity</b>: Constant.
Chris@101 738 key_compare key_comp() const;
Chris@16 739
Chris@16 740 //! <b>Effects</b>: Returns an object of value_compare constructed out
Chris@16 741 //! of the comparison object.
Chris@16 742 //!
Chris@16 743 //! <b>Complexity</b>: Constant.
Chris@101 744 value_compare value_comp() const;
Chris@16 745
Chris@16 746 //! <b>Returns</b>: An iterator pointing to an element with the key
Chris@16 747 //! equivalent to x, or end() if such an element is not found.
Chris@16 748 //!
Chris@16 749 //! <b>Complexity</b>: Logarithmic.
Chris@101 750 iterator find(const key_type& x);
Chris@16 751
Chris@101 752 //! <b>Returns</b>: A const_iterator pointing to an element with the key
Chris@16 753 //! equivalent to x, or end() if such an element is not found.
Chris@16 754 //!
Chris@16 755 //! <b>Complexity</b>: Logarithmic.
Chris@101 756 const_iterator find(const key_type& x) const;
Chris@101 757
Chris@101 758 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 759
Chris@16 760 //! <b>Returns</b>: The number of elements with key equivalent to x.
Chris@16 761 //!
Chris@16 762 //! <b>Complexity</b>: log(size())+count(k)
Chris@16 763 size_type count(const key_type& x) const
Chris@101 764 { return static_cast<size_type>(this->find(x) != this->cend()); }
Chris@101 765
Chris@101 766 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 767
Chris@16 768 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 769 //! than k, or a.end() if such an element is not found.
Chris@16 770 //!
Chris@16 771 //! <b>Complexity</b>: Logarithmic
Chris@101 772 iterator lower_bound(const key_type& x);
Chris@16 773
Chris@101 774 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 775 //! less than k, or a.end() if such an element is not found.
Chris@16 776 //!
Chris@16 777 //! <b>Complexity</b>: Logarithmic
Chris@101 778 const_iterator lower_bound(const key_type& x) const;
Chris@16 779
Chris@16 780 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 781 //! than x, or end() if such an element is not found.
Chris@16 782 //!
Chris@16 783 //! <b>Complexity</b>: Logarithmic
Chris@101 784 iterator upper_bound(const key_type& x);
Chris@16 785
Chris@101 786 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 787 //! less than x, or end() if such an element is not found.
Chris@16 788 //!
Chris@16 789 //! <b>Complexity</b>: Logarithmic
Chris@101 790 const_iterator upper_bound(const key_type& x) const;
Chris@16 791
Chris@16 792 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 793 //!
Chris@16 794 //! <b>Complexity</b>: Logarithmic
Chris@101 795 std::pair<iterator,iterator> equal_range(const key_type& x);
Chris@16 796
Chris@16 797 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 798 //!
Chris@16 799 //! <b>Complexity</b>: Logarithmic
Chris@101 800 std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
Chris@16 801
Chris@101 802 //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
Chris@101 803 //!
Chris@101 804 //! <b>Complexity</b>: Linear
Chris@101 805 void rebalance();
Chris@101 806
Chris@101 807 //! <b>Effects</b>: Returns true if x and y are equal
Chris@101 808 //!
Chris@101 809 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 810 friend bool operator==(const map& x, const map& y);
Chris@101 811
Chris@101 812 //! <b>Effects</b>: Returns true if x and y are unequal
Chris@101 813 //!
Chris@101 814 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 815 friend bool operator!=(const map& x, const map& y);
Chris@101 816
Chris@101 817 //! <b>Effects</b>: Returns true if x is less than y
Chris@101 818 //!
Chris@101 819 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 820 friend bool operator<(const map& x, const map& y);
Chris@101 821
Chris@101 822 //! <b>Effects</b>: Returns true if x is greater than y
Chris@101 823 //!
Chris@101 824 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 825 friend bool operator>(const map& x, const map& y);
Chris@101 826
Chris@101 827 //! <b>Effects</b>: Returns true if x is equal or less than y
Chris@101 828 //!
Chris@101 829 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 830 friend bool operator<=(const map& x, const map& y);
Chris@101 831
Chris@101 832 //! <b>Effects</b>: Returns true if x is equal or greater than y
Chris@101 833 //!
Chris@101 834 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 835 friend bool operator>=(const map& x, const map& y);
Chris@101 836
Chris@101 837 //! <b>Effects</b>: x.swap(y)
Chris@101 838 //!
Chris@101 839 //! <b>Complexity</b>: Constant.
Chris@101 840 friend void swap(map& x, map& y);
Chris@101 841
Chris@101 842 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@101 843
Chris@101 844 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 845 private:
Chris@16 846 mapped_type& priv_subscript(const key_type &k)
Chris@16 847 {
Chris@16 848 //we can optimize this
Chris@101 849 iterator i = this->lower_bound(k);
Chris@16 850 // i->first is greater than or equivalent to k.
Chris@101 851 if (i == this->end() || this->key_comp()(k, (*i).first)){
Chris@16 852 container_detail::value_init<mapped_type> m;
Chris@16 853 movable_value_type val(k, boost::move(m.m_t));
Chris@16 854 i = insert(i, boost::move(val));
Chris@16 855 }
Chris@16 856 return (*i).second;
Chris@16 857 }
Chris@16 858
Chris@16 859 mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk)
Chris@16 860 {
Chris@16 861 key_type &k = mk;
Chris@16 862 //we can optimize this
Chris@101 863 iterator i = this->lower_bound(k);
Chris@16 864 // i->first is greater than or equivalent to k.
Chris@101 865 if (i == this->end() || this->key_comp()(k, (*i).first)){
Chris@16 866 container_detail::value_init<mapped_type> m;
Chris@16 867 movable_value_type val(boost::move(k), boost::move(m.m_t));
Chris@16 868 i = insert(i, boost::move(val));
Chris@16 869 }
Chris@16 870 return (*i).second;
Chris@16 871 }
Chris@16 872
Chris@101 873 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 874 };
Chris@16 875
Chris@16 876
Chris@101 877 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 878
Chris@16 879 } //namespace container {
Chris@16 880
Chris@16 881 //!has_trivial_destructor_after_move<> == true_type
Chris@16 882 //!specialization for optimizations
Chris@101 883 template <class Key, class T, class Compare, class Allocator>
Chris@101 884 struct has_trivial_destructor_after_move<boost::container::map<Key, T, Compare, Allocator> >
Chris@16 885 {
Chris@101 886 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@101 887 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
Chris@101 888 ::boost::has_trivial_destructor_after_move<pointer>::value &&
Chris@101 889 ::boost::has_trivial_destructor_after_move<Compare>::value;
Chris@16 890 };
Chris@16 891
Chris@16 892 namespace container {
Chris@16 893
Chris@101 894 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@101 895
Chris@101 896 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 897
Chris@16 898 //! A multimap is a kind of associative container that supports equivalent keys
Chris@16 899 //! (possibly containing multiple copies of the same key value) and provides for
Chris@16 900 //! fast retrieval of values of another type T based on the keys. The multimap class
Chris@16 901 //! supports bidirectional iterators.
Chris@16 902 //!
Chris@16 903 //! A multimap satisfies all of the requirements of a container and of a reversible
Chris@101 904 //! container and of an associative container. The <code>value_type</code> stored
Chris@101 905 //! by this container is the value_type is std::pair<const Key, T>.
Chris@16 906 //!
Chris@101 907 //! \tparam Key is the key_type of the map
Chris@101 908 //! \tparam Value is the <code>mapped_type</code>
Chris@101 909 //! \tparam Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
Chris@101 910 //! \tparam Allocator is the allocator to allocate the <code>value_type</code>s
Chris@101 911 //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
Chris@101 912 //! \tparam MultiMapOptions is an packed option type generated using using boost::container::tree_assoc_options.
Chris@101 913 template < class Key, class T, class Compare = std::less<Key>
Chris@101 914 , class Allocator = new_allocator< std::pair< const Key, T> >, class MultiMapOptions = tree_assoc_defaults>
Chris@16 915 #else
Chris@101 916 template <class Key, class T, class Compare, class Allocator, class MultiMapOptions>
Chris@16 917 #endif
Chris@16 918 class multimap
Chris@101 919 ///@cond
Chris@101 920 : public container_detail::tree
Chris@101 921 < Key, std::pair<const Key, T>
Chris@101 922 , container_detail::select1st< std::pair<const Key, T> >
Chris@101 923 , Compare, Allocator, MultiMapOptions>
Chris@101 924 ///@endcond
Chris@16 925 {
Chris@101 926 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 927 private:
Chris@16 928 BOOST_COPYABLE_AND_MOVABLE(multimap)
Chris@16 929
Chris@16 930 typedef std::pair<const Key, T> value_type_impl;
Chris@101 931 typedef container_detail::tree
Chris@101 932 <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator, MultiMapOptions> base_t;
Chris@16 933 typedef container_detail::pair <Key, T> movable_value_type_impl;
Chris@16 934 typedef container_detail::tree_value_compare
Chris@16 935 < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
Chris@16 936 > value_compare_impl;
Chris@101 937 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@101 938
Chris@101 939 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
Chris@16 940
Chris@16 941 public:
Chris@16 942 //////////////////////////////////////////////
Chris@16 943 //
Chris@16 944 // types
Chris@16 945 //
Chris@16 946 //////////////////////////////////////////////
Chris@16 947
Chris@16 948 typedef Key key_type;
Chris@16 949 typedef T mapped_type;
Chris@16 950 typedef std::pair<const Key, T> value_type;
Chris@16 951 typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@16 952 typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
Chris@16 953 typedef typename boost::container::allocator_traits<Allocator>::reference reference;
Chris@16 954 typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
Chris@16 955 typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
Chris@16 956 typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
Chris@16 957 typedef Allocator allocator_type;
Chris@101 958 typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
Chris@16 959 typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
Chris@16 960 typedef Compare key_compare;
Chris@101 961 typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
Chris@101 962 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
Chris@101 963 typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
Chris@101 964 typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
Chris@16 965 typedef std::pair<key_type, mapped_type> nonconst_value_type;
Chris@16 966 typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
Chris@16 967
Chris@16 968 //////////////////////////////////////////////
Chris@16 969 //
Chris@16 970 // construct/copy/destroy
Chris@16 971 //
Chris@16 972 //////////////////////////////////////////////
Chris@16 973
Chris@16 974 //! <b>Effects</b>: Default constructs an empty multimap.
Chris@16 975 //!
Chris@16 976 //! <b>Complexity</b>: Constant.
Chris@16 977 multimap()
Chris@101 978 : base_t()
Chris@16 979 {
Chris@101 980 //A type must be std::pair<CONST Key, T>
Chris@16 981 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 982 }
Chris@16 983
Chris@16 984 //! <b>Effects</b>: Constructs an empty multimap using the specified allocator.
Chris@16 985 //!
Chris@16 986 //! <b>Complexity</b>: Constant.
Chris@16 987 explicit multimap(const Compare& comp, const allocator_type& a = allocator_type())
Chris@101 988 : base_t(comp, a)
Chris@16 989 {
Chris@101 990 //A type must be std::pair<CONST Key, T>
Chris@16 991 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 992 }
Chris@16 993
Chris@16 994 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison
Chris@16 995 //! object and allocator.
Chris@16 996 //!
Chris@16 997 //! <b>Complexity</b>: Constant.
Chris@16 998 explicit multimap(const allocator_type& a)
Chris@101 999 : base_t(a)
Chris@16 1000 {
Chris@101 1001 //A type must be std::pair<CONST Key, T>
Chris@16 1002 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1003 }
Chris@16 1004
Chris@16 1005 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object
Chris@16 1006 //! and allocator, and inserts elements from the range [first ,last ).
Chris@16 1007 //!
Chris@16 1008 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@16 1009 //! comp and otherwise N logN, where N is last - first.
Chris@16 1010 template <class InputIterator>
Chris@16 1011 multimap(InputIterator first, InputIterator last,
Chris@16 1012 const Compare& comp = Compare(),
Chris@16 1013 const allocator_type& a = allocator_type())
Chris@101 1014 : base_t(false, first, last, comp, a)
Chris@16 1015 {
Chris@101 1016 //A type must be std::pair<CONST Key, T>
Chris@101 1017 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 1018 }
Chris@101 1019
Chris@101 1020 //! <b>Effects</b>: Constructs an empty multimap using the specified
Chris@101 1021 //! allocator, and inserts elements from the range [first ,last ).
Chris@101 1022 //!
Chris@101 1023 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 1024 //! comp and otherwise N logN, where N is last - first.
Chris@101 1025 template <class InputIterator>
Chris@101 1026 multimap(InputIterator first, InputIterator last, const allocator_type& a)
Chris@101 1027 : base_t(false, first, last, Compare(), a)
Chris@101 1028 {
Chris@101 1029 //A type must be std::pair<CONST Key, T>
Chris@16 1030 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1031 }
Chris@16 1032
Chris@16 1033 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
Chris@16 1034 //! allocator, and inserts elements from the ordered range [first ,last). This function
Chris@16 1035 //! is more efficient than the normal range creation for ordered ranges.
Chris@16 1036 //!
Chris@16 1037 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
Chris@16 1038 //!
Chris@16 1039 //! <b>Complexity</b>: Linear in N.
Chris@16 1040 //!
Chris@16 1041 //! <b>Note</b>: Non-standard extension.
Chris@16 1042 template <class InputIterator>
Chris@16 1043 multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare(),
Chris@16 1044 const allocator_type& a = allocator_type())
Chris@101 1045 : base_t(ordered_range, first, last, comp, a)
Chris@16 1046 {}
Chris@16 1047
Chris@101 1048 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 1049 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
Chris@101 1050 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 1051 //!
Chris@101 1052 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 1053 //! comp and otherwise N logN, where N is il.first() - il.end().
Chris@101 1054 multimap(std::initializer_list<value_type> il, const Compare& comp = Compare(),
Chris@101 1055 const allocator_type& a = allocator_type())
Chris@101 1056 : base_t(false, il.begin(), il.end(), comp, a)
Chris@101 1057 {
Chris@101 1058 //A type must be std::pair<CONST Key, T>
Chris@101 1059 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 1060 }
Chris@101 1061
Chris@101 1062 //! <b>Effects</b>: Constructs an empty multimap using the specified
Chris@101 1063 //! allocator, and inserts elements from the range [il.begin(), il.end()).
Chris@101 1064 //!
Chris@101 1065 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
Chris@101 1066 //! comp and otherwise N logN, where N is il.first() - il.end().
Chris@101 1067 multimap(std::initializer_list<value_type> il, const allocator_type& a)
Chris@101 1068 : base_t(false, il.begin(), il.end(), Compare(), a)
Chris@101 1069 {
Chris@101 1070 //A type must be std::pair<CONST Key, T>
Chris@101 1071 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 1072 }
Chris@101 1073
Chris@101 1074 //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
Chris@101 1075 //! allocator, and inserts elements from the ordered range [il.begin(), il.end()). This function
Chris@101 1076 //! is more efficient than the normal range creation for ordered ranges.
Chris@101 1077 //!
Chris@101 1078 //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate.
Chris@101 1079 //!
Chris@101 1080 //! <b>Complexity</b>: Linear in N.
Chris@101 1081 //!
Chris@101 1082 //! <b>Note</b>: Non-standard extension.
Chris@101 1083 multimap(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp = Compare(),
Chris@101 1084 const allocator_type& a = allocator_type())
Chris@101 1085 : base_t(ordered_range, il.begin(), il.end(), comp, a)
Chris@101 1086 {
Chris@101 1087 //A type must be std::pair<CONST Key, T>
Chris@101 1088 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@101 1089 }
Chris@101 1090 #endif
Chris@101 1091
Chris@16 1092 //! <b>Effects</b>: Copy constructs a multimap.
Chris@16 1093 //!
Chris@16 1094 //! <b>Complexity</b>: Linear in x.size().
Chris@16 1095 multimap(const multimap& x)
Chris@101 1096 : base_t(static_cast<const base_t&>(x))
Chris@16 1097 {
Chris@101 1098 //A type must be std::pair<CONST Key, T>
Chris@16 1099 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1100 }
Chris@16 1101
Chris@16 1102 //! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources.
Chris@16 1103 //!
Chris@16 1104 //! <b>Complexity</b>: Constant.
Chris@16 1105 //!
Chris@16 1106 //! <b>Postcondition</b>: x is emptied.
Chris@16 1107 multimap(BOOST_RV_REF(multimap) x)
Chris@101 1108 : base_t(BOOST_MOVE_BASE(base_t, x))
Chris@16 1109 {
Chris@101 1110 //A type must be std::pair<CONST Key, T>
Chris@16 1111 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1112 }
Chris@16 1113
Chris@16 1114 //! <b>Effects</b>: Copy constructs a multimap.
Chris@16 1115 //!
Chris@16 1116 //! <b>Complexity</b>: Linear in x.size().
Chris@16 1117 multimap(const multimap& x, const allocator_type &a)
Chris@101 1118 : base_t(static_cast<const base_t&>(x), a)
Chris@16 1119 {
Chris@101 1120 //A type must be std::pair<CONST Key, T>
Chris@16 1121 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1122 }
Chris@16 1123
Chris@16 1124 //! <b>Effects</b>: Move constructs a multimap using the specified allocator.
Chris@16 1125 //! Constructs *this using x's resources.
Chris@16 1126 //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
Chris@16 1127 //!
Chris@16 1128 //! <b>Postcondition</b>: x is emptied.
Chris@16 1129 multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
Chris@101 1130 : base_t(BOOST_MOVE_BASE(base_t, x), a)
Chris@16 1131 {
Chris@101 1132 //A type must be std::pair<CONST Key, T>
Chris@16 1133 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
Chris@16 1134 }
Chris@16 1135
Chris@16 1136 //! <b>Effects</b>: Makes *this a copy of x.
Chris@16 1137 //!
Chris@16 1138 //! <b>Complexity</b>: Linear in x.size().
Chris@16 1139 multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
Chris@101 1140 { return static_cast<multimap&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
Chris@16 1141
Chris@16 1142 //! <b>Effects</b>: this->swap(x.get()).
Chris@16 1143 //!
Chris@16 1144 //! <b>Complexity</b>: Constant.
Chris@16 1145 multimap& operator=(BOOST_RV_REF(multimap) x)
Chris@101 1146 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 1147 && boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
Chris@101 1148 { return static_cast<multimap&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
Chris@16 1149
Chris@101 1150 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 1151 //! <b>Effects</b>: Assign content of il to *this.
Chris@16 1152 //!
Chris@101 1153 multimap& operator=(std::initializer_list<value_type> il)
Chris@101 1154 {
Chris@101 1155 this->clear();
Chris@101 1156 insert(il.begin(), il.end());
Chris@101 1157 return *this;
Chris@101 1158 }
Chris@101 1159 #endif
Chris@16 1160
Chris@101 1161 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1162
Chris@101 1163 //! @copydoc ::boost::container::set::get_allocator()
Chris@101 1164 allocator_type get_allocator() const;
Chris@16 1165
Chris@101 1166 //! @copydoc ::boost::container::set::get_stored_allocator()
Chris@101 1167 stored_allocator_type &get_stored_allocator();
Chris@16 1168
Chris@101 1169 //! @copydoc ::boost::container::set::get_stored_allocator() const
Chris@101 1170 const stored_allocator_type &get_stored_allocator() const;
Chris@16 1171
Chris@101 1172 //! @copydoc ::boost::container::set::begin()
Chris@101 1173 iterator begin();
Chris@16 1174
Chris@101 1175 //! @copydoc ::boost::container::set::begin() const
Chris@101 1176 const_iterator begin() const;
Chris@16 1177
Chris@101 1178 //! @copydoc ::boost::container::set::cbegin() const
Chris@101 1179 const_iterator cbegin() const;
Chris@16 1180
Chris@101 1181 //! @copydoc ::boost::container::set::end()
Chris@101 1182 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1183
Chris@101 1184 //! @copydoc ::boost::container::set::end() const
Chris@101 1185 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1186
Chris@101 1187 //! @copydoc ::boost::container::set::cend() const
Chris@101 1188 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1189
Chris@101 1190 //! @copydoc ::boost::container::set::rbegin()
Chris@101 1191 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1192
Chris@101 1193 //! @copydoc ::boost::container::set::rbegin() const
Chris@101 1194 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1195
Chris@101 1196 //! @copydoc ::boost::container::set::crbegin() const
Chris@101 1197 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1198
Chris@101 1199 //! @copydoc ::boost::container::set::rend()
Chris@101 1200 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1201
Chris@101 1202 //! @copydoc ::boost::container::set::rend() const
Chris@101 1203 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1204
Chris@101 1205 //! @copydoc ::boost::container::set::crend() const
Chris@101 1206 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1207
Chris@101 1208 //! @copydoc ::boost::container::set::empty() const
Chris@101 1209 bool empty() const;
Chris@16 1210
Chris@101 1211 //! @copydoc ::boost::container::set::size() const
Chris@101 1212 size_type size() const;
Chris@16 1213
Chris@101 1214 //! @copydoc ::boost::container::set::max_size() const
Chris@101 1215 size_type max_size() const;
Chris@16 1216
Chris@101 1217 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1218
Chris@101 1219 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1220
Chris@16 1221 //! <b>Effects</b>: Inserts an object of type T constructed with
Chris@16 1222 //! std::forward<Args>(args)... in the container.
Chris@16 1223 //! p is a hint pointing to where the insert should start to search.
Chris@16 1224 //!
Chris@16 1225 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1226 //! to the key of x.
Chris@16 1227 //!
Chris@16 1228 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1229 //! is inserted right before p.
Chris@16 1230 template <class... Args>
Chris@101 1231 iterator emplace(BOOST_FWD_REF(Args)... args)
Chris@101 1232 { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
Chris@16 1233
Chris@16 1234 //! <b>Effects</b>: Inserts an object of type T constructed with
Chris@16 1235 //! std::forward<Args>(args)... in the container.
Chris@16 1236 //! p is a hint pointing to where the insert should start to search.
Chris@16 1237 //!
Chris@16 1238 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1239 //! to the key of x.
Chris@16 1240 //!
Chris@16 1241 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1242 //! is inserted right before p.
Chris@16 1243 template <class... Args>
Chris@101 1244 iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
Chris@101 1245 { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
Chris@16 1246
Chris@101 1247 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 1248
Chris@101 1249 #define BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE(N) \
Chris@101 1250 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 1251 iterator emplace(BOOST_MOVE_UREF##N)\
Chris@101 1252 { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
Chris@101 1253 \
Chris@101 1254 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
Chris@101 1255 iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
Chris@101 1256 { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
Chris@101 1257 //
Chris@101 1258 BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE)
Chris@101 1259 #undef BOOST_CONTAINER_MULTIMAP_EMPLACE_CODE
Chris@16 1260
Chris@101 1261 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@16 1262
Chris@16 1263 //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
Chris@16 1264 //! newly inserted element.
Chris@16 1265 //!
Chris@16 1266 //! <b>Complexity</b>: Logarithmic.
Chris@16 1267 iterator insert(const value_type& x)
Chris@101 1268 { return this->base_t::insert_equal(x); }
Chris@16 1269
Chris@16 1270 //! <b>Effects</b>: Inserts a new value constructed from x and returns
Chris@16 1271 //! the iterator pointing to the newly inserted element.
Chris@16 1272 //!
Chris@16 1273 //! <b>Complexity</b>: Logarithmic.
Chris@16 1274 iterator insert(const nonconst_value_type& x)
Chris@101 1275 { return this->base_t::insert_equal(x); }
Chris@16 1276
Chris@16 1277 //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
Chris@16 1278 //! the iterator pointing to the newly inserted element.
Chris@16 1279 //!
Chris@16 1280 //! <b>Complexity</b>: Logarithmic.
Chris@16 1281 iterator insert(BOOST_RV_REF(nonconst_value_type) x)
Chris@101 1282 { return this->base_t::insert_equal(boost::move(x)); }
Chris@16 1283
Chris@16 1284 //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
Chris@16 1285 //! the iterator pointing to the newly inserted element.
Chris@16 1286 //!
Chris@16 1287 //! <b>Complexity</b>: Logarithmic.
Chris@16 1288 iterator insert(BOOST_RV_REF(movable_value_type) x)
Chris@101 1289 { return this->base_t::insert_equal(boost::move(x)); }
Chris@16 1290
Chris@16 1291 //! <b>Effects</b>: Inserts a copy of x in the container.
Chris@16 1292 //! p is a hint pointing to where the insert should start to search.
Chris@16 1293 //!
Chris@16 1294 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1295 //! to the key of x.
Chris@16 1296 //!
Chris@16 1297 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1298 //! is inserted right before p.
Chris@101 1299 iterator insert(const_iterator p, const value_type& x)
Chris@101 1300 { return this->base_t::insert_equal(p, x); }
Chris@16 1301
Chris@16 1302 //! <b>Effects</b>: Inserts a new value constructed from x in the container.
Chris@16 1303 //! p is a hint pointing to where the insert should start to search.
Chris@16 1304 //!
Chris@16 1305 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1306 //! to the key of x.
Chris@16 1307 //!
Chris@16 1308 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1309 //! is inserted right before p.
Chris@101 1310 iterator insert(const_iterator p, const nonconst_value_type& x)
Chris@101 1311 { return this->base_t::insert_equal(p, x); }
Chris@16 1312
Chris@16 1313 //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
Chris@16 1314 //! p is a hint pointing to where the insert should start to search.
Chris@16 1315 //!
Chris@16 1316 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1317 //! to the key of x.
Chris@16 1318 //!
Chris@16 1319 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1320 //! is inserted right before p.
Chris@101 1321 iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x)
Chris@101 1322 { return this->base_t::insert_equal(p, boost::move(x)); }
Chris@16 1323
Chris@16 1324 //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
Chris@16 1325 //! p is a hint pointing to where the insert should start to search.
Chris@16 1326 //!
Chris@16 1327 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
Chris@16 1328 //! to the key of x.
Chris@16 1329 //!
Chris@16 1330 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
Chris@16 1331 //! is inserted right before p.
Chris@101 1332 iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x)
Chris@101 1333 { return this->base_t::insert_equal(p, boost::move(x)); }
Chris@16 1334
Chris@16 1335 //! <b>Requires</b>: first, last are not iterators into *this.
Chris@16 1336 //!
Chris@16 1337 //! <b>Effects</b>: inserts each element from the range [first,last) .
Chris@16 1338 //!
Chris@16 1339 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
Chris@16 1340 template <class InputIterator>
Chris@16 1341 void insert(InputIterator first, InputIterator last)
Chris@101 1342 { this->base_t::insert_equal(first, last); }
Chris@16 1343
Chris@101 1344 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
Chris@101 1345 //! <b>Effects</b>: inserts each element from the range [il.begin(), il.end().
Chris@16 1346 //!
Chris@101 1347 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
Chris@101 1348 void insert(std::initializer_list<value_type> il)
Chris@101 1349 { this->base_t::insert_equal(il.begin(), il.end()); }
Chris@101 1350 #endif
Chris@16 1351
Chris@101 1352 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1353
Chris@101 1354 //! @copydoc ::boost::container::set::erase(const_iterator)
Chris@101 1355 iterator erase(const_iterator p);
Chris@16 1356
Chris@101 1357 //! @copydoc ::boost::container::set::erase(const key_type&)
Chris@101 1358 size_type erase(const key_type& x);
Chris@16 1359
Chris@101 1360 //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
Chris@101 1361 iterator erase(const_iterator first, const_iterator last);
Chris@16 1362
Chris@101 1363 //! @copydoc ::boost::container::set::swap
Chris@101 1364 void swap(multiset& x)
Chris@101 1365 BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
Chris@101 1366 && boost::container::container_detail::is_nothrow_swappable<Compare>::value );
Chris@16 1367
Chris@101 1368 //! @copydoc ::boost::container::set::clear
Chris@101 1369 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
Chris@16 1370
Chris@101 1371 //! @copydoc ::boost::container::set::key_comp
Chris@101 1372 key_compare key_comp() const;
Chris@16 1373
Chris@101 1374 //! @copydoc ::boost::container::set::value_comp
Chris@101 1375 value_compare value_comp() const;
Chris@16 1376
Chris@16 1377 //! <b>Returns</b>: An iterator pointing to an element with the key
Chris@16 1378 //! equivalent to x, or end() if such an element is not found.
Chris@16 1379 //!
Chris@16 1380 //! <b>Complexity</b>: Logarithmic.
Chris@101 1381 iterator find(const key_type& x);
Chris@16 1382
Chris@101 1383 //! <b>Returns</b>: A const iterator pointing to an element with the key
Chris@16 1384 //! equivalent to x, or end() if such an element is not found.
Chris@16 1385 //!
Chris@16 1386 //! <b>Complexity</b>: Logarithmic.
Chris@101 1387 const_iterator find(const key_type& x) const;
Chris@16 1388
Chris@16 1389 //! <b>Returns</b>: The number of elements with key equivalent to x.
Chris@16 1390 //!
Chris@16 1391 //! <b>Complexity</b>: log(size())+count(k)
Chris@101 1392 size_type count(const key_type& x) const;
Chris@16 1393
Chris@16 1394 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 1395 //! than k, or a.end() if such an element is not found.
Chris@16 1396 //!
Chris@16 1397 //! <b>Complexity</b>: Logarithmic
Chris@101 1398 iterator lower_bound(const key_type& x);
Chris@16 1399
Chris@101 1400 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 1401 //! less than k, or a.end() if such an element is not found.
Chris@16 1402 //!
Chris@16 1403 //! <b>Complexity</b>: Logarithmic
Chris@101 1404 const_iterator lower_bound(const key_type& x) const;
Chris@16 1405
Chris@16 1406 //! <b>Returns</b>: An iterator pointing to the first element with key not less
Chris@16 1407 //! than x, or end() if such an element is not found.
Chris@16 1408 //!
Chris@16 1409 //! <b>Complexity</b>: Logarithmic
Chris@101 1410 iterator upper_bound(const key_type& x);
Chris@16 1411
Chris@101 1412 //! <b>Returns</b>: A const iterator pointing to the first element with key not
Chris@16 1413 //! less than x, or end() if such an element is not found.
Chris@16 1414 //!
Chris@16 1415 //! <b>Complexity</b>: Logarithmic
Chris@101 1416 const_iterator upper_bound(const key_type& x) const;
Chris@16 1417
Chris@16 1418 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 1419 //!
Chris@16 1420 //! <b>Complexity</b>: Logarithmic
Chris@101 1421 std::pair<iterator,iterator> equal_range(const key_type& x);
Chris@16 1422
Chris@16 1423 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
Chris@16 1424 //!
Chris@16 1425 //! <b>Complexity</b>: Logarithmic
Chris@101 1426 std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
Chris@16 1427
Chris@101 1428 //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
Chris@101 1429 //!
Chris@101 1430 //! <b>Complexity</b>: Linear
Chris@101 1431 void rebalance();
Chris@16 1432
Chris@101 1433 //! <b>Effects</b>: Returns true if x and y are equal
Chris@101 1434 //!
Chris@101 1435 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1436 friend bool operator==(const multimap& x, const multimap& y);
Chris@101 1437
Chris@101 1438 //! <b>Effects</b>: Returns true if x and y are unequal
Chris@101 1439 //!
Chris@101 1440 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1441 friend bool operator!=(const multimap& x, const multimap& y);
Chris@101 1442
Chris@101 1443 //! <b>Effects</b>: Returns true if x is less than y
Chris@101 1444 //!
Chris@101 1445 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1446 friend bool operator<(const multimap& x, const multimap& y);
Chris@101 1447
Chris@101 1448 //! <b>Effects</b>: Returns true if x is greater than y
Chris@101 1449 //!
Chris@101 1450 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1451 friend bool operator>(const multimap& x, const multimap& y);
Chris@101 1452
Chris@101 1453 //! <b>Effects</b>: Returns true if x is equal or less than y
Chris@101 1454 //!
Chris@101 1455 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1456 friend bool operator<=(const multimap& x, const multimap& y);
Chris@101 1457
Chris@101 1458 //! <b>Effects</b>: Returns true if x is equal or greater than y
Chris@101 1459 //!
Chris@101 1460 //! <b>Complexity</b>: Linear to the number of elements in the container.
Chris@101 1461 friend bool operator>=(const multimap& x, const multimap& y);
Chris@101 1462
Chris@101 1463 //! <b>Effects</b>: x.swap(y)
Chris@101 1464 //!
Chris@101 1465 //! <b>Complexity</b>: Constant.
Chris@101 1466 friend void swap(multimap& x, multimap& y);
Chris@101 1467
Chris@101 1468 #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
Chris@16 1469 };
Chris@16 1470
Chris@101 1471 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1472
Chris@16 1473 } //namespace container {
Chris@16 1474
Chris@16 1475 //!has_trivial_destructor_after_move<> == true_type
Chris@16 1476 //!specialization for optimizations
Chris@101 1477 template <class Key, class T, class Compare, class Allocator>
Chris@101 1478 struct has_trivial_destructor_after_move<boost::container::multimap<Key, T, Compare, Allocator> >
Chris@16 1479 {
Chris@101 1480 typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
Chris@101 1481 static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
Chris@101 1482 ::boost::has_trivial_destructor_after_move<pointer>::value &&
Chris@101 1483 ::boost::has_trivial_destructor_after_move<Compare>::value;
Chris@16 1484 };
Chris@16 1485
Chris@16 1486 namespace container {
Chris@16 1487
Chris@101 1488 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
Chris@16 1489
Chris@16 1490 }}
Chris@16 1491
Chris@16 1492 #include <boost/container/detail/config_end.hpp>
Chris@16 1493
Chris@101 1494 #endif // BOOST_CONTAINER_MAP_HPP
Chris@16 1495