annotate DEPENDENCIES/generic/include/boost/container/flat_set.hpp @ 16:2665513ce2d3

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