annotate DEPENDENCIES/generic/include/boost/intrusive/unordered_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 Olaf Krzikalla 2004-2006.
Chris@16 4 // (C) Copyright Ion Gaztanaga 2006-2013
Chris@16 5 //
Chris@16 6 // Distributed under the Boost Software License, Version 1.0.
Chris@16 7 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 8 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10 // See http://www.boost.org/libs/intrusive for documentation.
Chris@16 11 //
Chris@16 12 /////////////////////////////////////////////////////////////////////////////
Chris@16 13 #ifndef BOOST_INTRUSIVE_UNORDERED_SET_HPP
Chris@16 14 #define BOOST_INTRUSIVE_UNORDERED_SET_HPP
Chris@16 15
Chris@16 16 #include <boost/intrusive/detail/config_begin.hpp>
Chris@16 17 #include <boost/intrusive/intrusive_fwd.hpp>
Chris@16 18 #include <boost/intrusive/hashtable.hpp>
Chris@16 19 #include <boost/move/move.hpp>
Chris@16 20 #include <iterator>
Chris@16 21
Chris@16 22
Chris@16 23 namespace boost {
Chris@16 24 namespace intrusive {
Chris@16 25
Chris@16 26 //! The class template unordered_set is an intrusive container, that mimics most of
Chris@16 27 //! the interface of std::tr1::unordered_set as described in the C++ TR1.
Chris@16 28 //!
Chris@16 29 //! unordered_set is a semi-intrusive container: each object to be stored in the
Chris@16 30 //! container must contain a proper hook, but the container also needs
Chris@16 31 //! additional auxiliary memory to work: unordered_set needs a pointer to an array
Chris@16 32 //! of type `bucket_type` to be passed in the constructor. This bucket array must
Chris@16 33 //! have at least the same lifetime as the container. This makes the use of
Chris@16 34 //! unordered_set more complicated than purely intrusive containers.
Chris@16 35 //! `bucket_type` is default-constructible, copyable and assignable
Chris@16 36 //!
Chris@16 37 //! The template parameter \c T is the type to be managed by the container.
Chris@16 38 //! The user can specify additional options and if no options are provided
Chris@16 39 //! default options are used.
Chris@16 40 //!
Chris@16 41 //! The container supports the following options:
Chris@16 42 //! \c base_hook<>/member_hook<>/value_traits<>,
Chris@16 43 //! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
Chris@16 44 //! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>.
Chris@16 45 //!
Chris@16 46 //! unordered_set only provides forward iterators but it provides 4 iterator types:
Chris@16 47 //! iterator and const_iterator to navigate through the whole container and
Chris@16 48 //! local_iterator and const_local_iterator to navigate through the values
Chris@16 49 //! stored in a single bucket. Local iterators are faster and smaller.
Chris@16 50 //!
Chris@16 51 //! It's not recommended to use non constant-time size unordered_sets because several
Chris@16 52 //! key functions, like "empty()", become non-constant time functions. Non
Chris@16 53 //! constant-time size unordered_sets are mainly provided to support auto-unlink hooks.
Chris@16 54 //!
Chris@16 55 //! unordered_set, unlike std::unordered_set, does not make automatic rehashings nor
Chris@16 56 //! offers functions related to a load factor. Rehashing can be explicitly requested
Chris@16 57 //! and the user must provide a new bucket array that will be used from that moment.
Chris@16 58 //!
Chris@16 59 //! Since no automatic rehashing is done, iterators are never invalidated when
Chris@16 60 //! inserting or erasing elements. Iterators are only invalidated when rehasing.
Chris@16 61 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
Chris@16 62 template<class T, class ...Options>
Chris@16 63 #else
Chris@16 64 template<class ValueTraits, class Hash, class Equal, class SizeType, class BucketTraits, std::size_t BoolFlags>
Chris@16 65 #endif
Chris@16 66 class unordered_set_impl
Chris@16 67 : public hashtable_impl<ValueTraits, Hash, Equal, SizeType, BucketTraits, BoolFlags>
Chris@16 68 {
Chris@16 69 /// @cond
Chris@16 70 private:
Chris@16 71 typedef hashtable_impl<ValueTraits, Hash, Equal, SizeType, BucketTraits, BoolFlags> table_type;
Chris@16 72
Chris@16 73 //! This class is
Chris@16 74 //! movable
Chris@16 75 BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set_impl)
Chris@16 76
Chris@16 77 typedef table_type implementation_defined;
Chris@16 78 /// @endcond
Chris@16 79
Chris@16 80 public:
Chris@16 81 typedef typename implementation_defined::value_type value_type;
Chris@16 82 typedef typename implementation_defined::value_traits value_traits;
Chris@16 83 typedef typename implementation_defined::bucket_traits bucket_traits;
Chris@16 84 typedef typename implementation_defined::pointer pointer;
Chris@16 85 typedef typename implementation_defined::const_pointer const_pointer;
Chris@16 86 typedef typename implementation_defined::reference reference;
Chris@16 87 typedef typename implementation_defined::const_reference const_reference;
Chris@16 88 typedef typename implementation_defined::difference_type difference_type;
Chris@16 89 typedef typename implementation_defined::size_type size_type;
Chris@16 90 typedef typename implementation_defined::key_type key_type;
Chris@16 91 typedef typename implementation_defined::key_equal key_equal;
Chris@16 92 typedef typename implementation_defined::hasher hasher;
Chris@16 93 typedef typename implementation_defined::bucket_type bucket_type;
Chris@16 94 typedef typename implementation_defined::bucket_ptr bucket_ptr;
Chris@16 95 typedef typename implementation_defined::iterator iterator;
Chris@16 96 typedef typename implementation_defined::const_iterator const_iterator;
Chris@16 97 typedef typename implementation_defined::insert_commit_data insert_commit_data;
Chris@16 98 typedef typename implementation_defined::local_iterator local_iterator;
Chris@16 99 typedef typename implementation_defined::const_local_iterator const_local_iterator;
Chris@16 100 typedef typename implementation_defined::node_traits node_traits;
Chris@16 101 typedef typename implementation_defined::node node;
Chris@16 102 typedef typename implementation_defined::node_ptr node_ptr;
Chris@16 103 typedef typename implementation_defined::const_node_ptr const_node_ptr;
Chris@16 104 typedef typename implementation_defined::node_algorithms node_algorithms;
Chris@16 105
Chris@16 106 public:
Chris@16 107
Chris@16 108 //! <b>Requires</b>: buckets must not be being used by any other resource.
Chris@16 109 //!
Chris@16 110 //! <b>Effects</b>: Constructs an empty unordered_set_impl, storing a reference
Chris@16 111 //! to the bucket array and copies of the hasher and equal functors.
Chris@16 112 //!
Chris@16 113 //! <b>Complexity</b>: Constant.
Chris@16 114 //!
Chris@16 115 //! <b>Throws</b>: If value_traits::node_traits::node
Chris@16 116 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
Chris@16 117 //! or the copy constructor or invocation of Hash or Equal throws.
Chris@16 118 //!
Chris@16 119 //! <b>Notes</b>: buckets array must be disposed only after
Chris@16 120 //! *this is disposed.
Chris@16 121 explicit unordered_set_impl( const bucket_traits &b_traits
Chris@16 122 , const hasher & hash_func = hasher()
Chris@16 123 , const key_equal &equal_func = key_equal()
Chris@16 124 , const value_traits &v_traits = value_traits())
Chris@16 125 : table_type(b_traits, hash_func, equal_func, v_traits)
Chris@16 126 {}
Chris@16 127
Chris@16 128 //! <b>Requires</b>: buckets must not be being used by any other resource
Chris@16 129 //! and Dereferencing iterator must yield an lvalue of type value_type.
Chris@16 130 //!
Chris@16 131 //! <b>Effects</b>: Constructs an empty unordered_set and inserts elements from
Chris@16 132 //! [b, e).
Chris@16 133 //!
Chris@16 134 //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N)
Chris@16 135 //! (with a good hash function and with buckets_len >= N),worst case O(N2).
Chris@16 136 //!
Chris@16 137 //! <b>Throws</b>: If value_traits::node_traits::node
Chris@16 138 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
Chris@16 139 //! or the copy constructor or invocation of hasher or key_equal throws.
Chris@16 140 //!
Chris@16 141 //! <b>Notes</b>: buckets array must be disposed only after
Chris@16 142 //! *this is disposed.
Chris@16 143 template<class Iterator>
Chris@16 144 unordered_set_impl( Iterator b
Chris@16 145 , Iterator e
Chris@16 146 , const bucket_traits &b_traits
Chris@16 147 , const hasher & hash_func = hasher()
Chris@16 148 , const key_equal &equal_func = key_equal()
Chris@16 149 , const value_traits &v_traits = value_traits())
Chris@16 150 : table_type(b_traits, hash_func, equal_func, v_traits)
Chris@16 151 { table_type::insert_unique(b, e); }
Chris@16 152
Chris@16 153 //! <b>Effects</b>: to-do
Chris@16 154 //!
Chris@16 155 unordered_set_impl(BOOST_RV_REF(unordered_set_impl) x)
Chris@16 156 : table_type(::boost::move(static_cast<table_type&>(x)))
Chris@16 157 {}
Chris@16 158
Chris@16 159 //! <b>Effects</b>: to-do
Chris@16 160 //!
Chris@16 161 unordered_set_impl& operator=(BOOST_RV_REF(unordered_set_impl) x)
Chris@16 162 { return static_cast<unordered_set_impl&>(table_type::operator=(::boost::move(static_cast<table_type&>(x)))); }
Chris@16 163
Chris@16 164 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 165 //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_set
Chris@16 166 //! are not deleted (i.e. no destructors are called).
Chris@16 167 //!
Chris@16 168 //! <b>Complexity</b>: Linear to the number of elements in the unordered_set, if
Chris@16 169 //! it's a safe-mode or auto-unlink value. Otherwise constant.
Chris@16 170 //!
Chris@16 171 //! <b>Throws</b>: Nothing.
Chris@16 172 ~unordered_set_impl()
Chris@16 173 {}
Chris@16 174
Chris@16 175 //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_set.
Chris@16 176 //!
Chris@16 177 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 178 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 179 //!
Chris@16 180 //! <b>Throws</b>: Nothing.
Chris@16 181 iterator begin()
Chris@16 182 { return table_type::begin(); }
Chris@16 183
Chris@16 184 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning
Chris@16 185 //! of the unordered_set.
Chris@16 186 //!
Chris@16 187 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 188 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 189 //!
Chris@16 190 //! <b>Throws</b>: Nothing.
Chris@16 191 const_iterator begin() const
Chris@16 192 { return table_type::begin(); }
Chris@16 193
Chris@16 194 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning
Chris@16 195 //! of the unordered_set.
Chris@16 196 //!
Chris@16 197 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 198 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 199 //!
Chris@16 200 //! <b>Throws</b>: Nothing.
Chris@16 201 const_iterator cbegin() const
Chris@16 202 { return table_type::cbegin(); }
Chris@16 203
Chris@16 204 //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_set.
Chris@16 205 //!
Chris@16 206 //! <b>Complexity</b>: Constant.
Chris@16 207 //!
Chris@16 208 //! <b>Throws</b>: Nothing.
Chris@16 209 iterator end()
Chris@16 210 { return table_type::end(); }
Chris@16 211
Chris@16 212 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set.
Chris@16 213 //!
Chris@16 214 //! <b>Complexity</b>: Constant.
Chris@16 215 //!
Chris@16 216 //! <b>Throws</b>: Nothing.
Chris@16 217 const_iterator end() const
Chris@16 218 { return table_type::end(); }
Chris@16 219
Chris@16 220 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set.
Chris@16 221 //!
Chris@16 222 //! <b>Complexity</b>: Constant.
Chris@16 223 //!
Chris@16 224 //! <b>Throws</b>: Nothing.
Chris@16 225 const_iterator cend() const
Chris@16 226 { return table_type::cend(); }
Chris@16 227
Chris@16 228 //! <b>Effects</b>: Returns the hasher object used by the unordered_set.
Chris@16 229 //!
Chris@16 230 //! <b>Complexity</b>: Constant.
Chris@16 231 //!
Chris@16 232 //! <b>Throws</b>: If hasher copy-constructor throws.
Chris@16 233 hasher hash_function() const
Chris@16 234 { return table_type::hash_function(); }
Chris@16 235
Chris@16 236 //! <b>Effects</b>: Returns the key_equal object used by the unordered_set.
Chris@16 237 //!
Chris@16 238 //! <b>Complexity</b>: Constant.
Chris@16 239 //!
Chris@16 240 //! <b>Throws</b>: If key_equal copy-constructor throws.
Chris@16 241 key_equal key_eq() const
Chris@16 242 { return table_type::key_eq(); }
Chris@16 243
Chris@16 244 //! <b>Effects</b>: Returns true if the container is empty.
Chris@16 245 //!
Chris@16 246 //! <b>Complexity</b>: if constant-time size and cache_last options are disabled,
Chris@16 247 //! average constant time (worst case, with empty() == true: O(this->bucket_count()).
Chris@16 248 //! Otherwise constant.
Chris@16 249 //!
Chris@16 250 //! <b>Throws</b>: Nothing.
Chris@16 251 bool empty() const
Chris@16 252 { return table_type::empty(); }
Chris@16 253
Chris@16 254 //! <b>Effects</b>: Returns the number of elements stored in the unordered_set.
Chris@16 255 //!
Chris@16 256 //! <b>Complexity</b>: Linear to elements contained in *this if
Chris@16 257 //! constant-time size option is disabled. Constant-time otherwise.
Chris@16 258 //!
Chris@16 259 //! <b>Throws</b>: Nothing.
Chris@16 260 size_type size() const
Chris@16 261 { return table_type::size(); }
Chris@16 262
Chris@16 263 //! <b>Requires</b>: the hasher and the equality function unqualified swap
Chris@16 264 //! call should not throw.
Chris@16 265 //!
Chris@16 266 //! <b>Effects</b>: Swaps the contents of two unordered_sets.
Chris@16 267 //! Swaps also the contained bucket array and equality and hasher functors.
Chris@16 268 //!
Chris@16 269 //! <b>Complexity</b>: Constant.
Chris@16 270 //!
Chris@16 271 //! <b>Throws</b>: If the swap() call for the comparison or hash functors
Chris@16 272 //! found using ADL throw. Basic guarantee.
Chris@16 273 void swap(unordered_set_impl& other)
Chris@16 274 { table_type::swap(other.table_); }
Chris@16 275
Chris@16 276 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 277 //! Cloner should yield to nodes that compare equal and produce the same
Chris@16 278 //! hash than the original node.
Chris@16 279 //!
Chris@16 280 //! <b>Effects</b>: Erases all the elements from *this
Chris@16 281 //! calling Disposer::operator()(pointer), clones all the
Chris@16 282 //! elements from src calling Cloner::operator()(const_reference )
Chris@16 283 //! and inserts them on *this. The hash function and the equality
Chris@16 284 //! predicate are copied from the source.
Chris@16 285 //!
Chris@16 286 //! If store_hash option is true, this method does not use the hash function.
Chris@16 287 //!
Chris@16 288 //! If any operation throws, all cloned elements are unlinked and disposed
Chris@16 289 //! calling Disposer::operator()(pointer).
Chris@16 290 //!
Chris@16 291 //! <b>Complexity</b>: Linear to erased plus inserted elements.
Chris@16 292 //!
Chris@16 293 //! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying
Chris@16 294 //! throws. Basic guarantee.
Chris@16 295 template <class Cloner, class Disposer>
Chris@16 296 void clone_from(const unordered_set_impl &src, Cloner cloner, Disposer disposer)
Chris@16 297 { table_type::clone_from(src.table_, cloner, disposer); }
Chris@16 298
Chris@16 299 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 300
Chris@16 301 //! <b>Requires</b>: value must be an lvalue
Chris@16 302 //!
Chris@16 303 //! <b>Effects</b>: Tries to inserts value into the unordered_set.
Chris@16 304 //!
Chris@16 305 //! <b>Returns</b>: If the value
Chris@16 306 //! is not already present inserts it and returns a pair containing the
Chris@16 307 //! iterator to the new value and true. If there is an equivalent value
Chris@16 308 //! returns a pair containing an iterator to the already present value
Chris@16 309 //! and false.
Chris@16 310 //!
Chris@16 311 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 312 //!
Chris@16 313 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.
Chris@16 314 //!
Chris@16 315 //! <b>Note</b>: Does not affect the validity of iterators and references.
Chris@16 316 //! No copy-constructors are called.
Chris@16 317 std::pair<iterator, bool> insert(reference value)
Chris@16 318 { return table_type::insert_unique(value); }
Chris@16 319
Chris@16 320 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
Chris@16 321 //! of type value_type.
Chris@16 322 //!
Chris@16 323 //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e).
Chris@16 324 //!
Chris@16 325 //! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e).
Chris@16 326 //! Worst case O(N*this->size()).
Chris@16 327 //!
Chris@16 328 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 329 //!
Chris@16 330 //! <b>Note</b>: Does not affect the validity of iterators and references.
Chris@16 331 //! No copy-constructors are called.
Chris@16 332 template<class Iterator>
Chris@16 333 void insert(Iterator b, Iterator e)
Chris@16 334 { table_type::insert_unique(b, e); }
Chris@16 335
Chris@16 336 //! <b>Requires</b>: "hasher" must be a hash function that induces
Chris@16 337 //! the same hash values as the stored hasher. The difference is that
Chris@16 338 //! "hasher" hashes the given key instead of the value_type.
Chris@16 339 //!
Chris@16 340 //! "key_value_equal" must be a equality function that induces
Chris@16 341 //! the same equality as key_equal. The difference is that
Chris@16 342 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 343 //!
Chris@16 344 //! <b>Effects</b>: Checks if a value can be inserted in the unordered_set, using
Chris@16 345 //! a user provided key instead of the value itself.
Chris@16 346 //!
Chris@16 347 //! <b>Returns</b>: If there is an equivalent value
Chris@16 348 //! returns a pair containing an iterator to the already present value
Chris@16 349 //! and false. If the value can be inserted returns true in the returned
Chris@16 350 //! pair boolean and fills "commit_data" that is meant to be used with
Chris@16 351 //! the "insert_commit" function.
Chris@16 352 //!
Chris@16 353 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 354 //!
Chris@16 355 //! <b>Throws</b>: If hasher or key_value_equal throw. Strong guarantee.
Chris@16 356 //!
Chris@16 357 //! <b>Notes</b>: This function is used to improve performance when constructing
Chris@16 358 //! a value_type is expensive: if there is an equivalent value
Chris@16 359 //! the constructed object must be discarded. Many times, the part of the
Chris@16 360 //! node that is used to impose the hash or the equality is much cheaper to
Chris@16 361 //! construct than the value_type and this function offers the possibility to
Chris@16 362 //! use that the part to check if the insertion will be successful.
Chris@16 363 //!
Chris@16 364 //! If the check is successful, the user can construct the value_type and use
Chris@16 365 //! "insert_commit" to insert the object in constant-time.
Chris@16 366 //!
Chris@16 367 //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
Chris@16 368 //! objects are inserted or erased from the unordered_set.
Chris@16 369 //!
Chris@16 370 //! After a successful rehashing insert_commit_data remains valid.
Chris@16 371 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 372 std::pair<iterator, bool> insert_check
Chris@16 373 (const KeyType &key, KeyHasher hasher, KeyValueEqual key_value_equal, insert_commit_data &commit_data)
Chris@16 374 { return table_type::insert_unique_check(key, hasher, key_value_equal, commit_data); }
Chris@16 375
Chris@16 376 //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
Chris@16 377 //! must have been obtained from a previous call to "insert_check".
Chris@16 378 //! No objects should have been inserted or erased from the unordered_set between
Chris@16 379 //! the "insert_check" that filled "commit_data" and the call to "insert_commit".
Chris@16 380 //!
Chris@16 381 //! <b>Effects</b>: Inserts the value in the unordered_set using the information obtained
Chris@16 382 //! from the "commit_data" that a previous "insert_check" filled.
Chris@16 383 //!
Chris@16 384 //! <b>Returns</b>: An iterator to the newly inserted object.
Chris@16 385 //!
Chris@16 386 //! <b>Complexity</b>: Constant time.
Chris@16 387 //!
Chris@16 388 //! <b>Throws</b>: Nothing.
Chris@16 389 //!
Chris@16 390 //! <b>Notes</b>: This function has only sense if a "insert_check" has been
Chris@16 391 //! previously executed to fill "commit_data". No value should be inserted or
Chris@16 392 //! erased between the "insert_check" and "insert_commit" calls.
Chris@16 393 //!
Chris@16 394 //! After a successful rehashing insert_commit_data remains valid.
Chris@16 395 iterator insert_commit(reference value, const insert_commit_data &commit_data)
Chris@16 396 { return table_type::insert_unique_commit(value, commit_data); }
Chris@16 397
Chris@16 398 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 399
Chris@16 400 //! <b>Effects</b>: Erases the element pointed to by i.
Chris@16 401 //!
Chris@16 402 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 403 //!
Chris@16 404 //! <b>Throws</b>: Nothing.
Chris@16 405 //!
Chris@16 406 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 407 //! to the erased element. No destructors are called.
Chris@16 408 void erase(const_iterator i)
Chris@16 409 { table_type::erase(i); }
Chris@16 410
Chris@16 411 //! <b>Effects</b>: Erases the range pointed to by b end e.
Chris@16 412 //!
Chris@16 413 //! <b>Complexity</b>: Average case O(std::distance(b, e)),
Chris@16 414 //! worst case O(this->size()).
Chris@16 415 //!
Chris@16 416 //! <b>Throws</b>: Nothing.
Chris@16 417 //!
Chris@16 418 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 419 //! to the erased elements. No destructors are called.
Chris@16 420 void erase(const_iterator b, const_iterator e)
Chris@16 421 { table_type::erase(b, e); }
Chris@16 422
Chris@16 423 //! <b>Effects</b>: Erases all the elements with the given value.
Chris@16 424 //!
Chris@16 425 //! <b>Returns</b>: The number of erased elements.
Chris@16 426 //!
Chris@16 427 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 428 //! Worst case O(this->size()).
Chris@16 429 //!
Chris@16 430 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 431 //!
Chris@16 432 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 433 //! to the erased elements. No destructors are called.
Chris@16 434 size_type erase(const_reference value)
Chris@16 435 { return table_type::erase(value); }
Chris@16 436
Chris@16 437 //! <b>Requires</b>: "hasher" must be a hash function that induces
Chris@16 438 //! the same hash values as the stored hasher. The difference is that
Chris@16 439 //! "hasher" hashes the given key instead of the value_type.
Chris@16 440 //!
Chris@16 441 //! "key_value_equal" must be a equality function that induces
Chris@16 442 //! the same equality as key_equal. The difference is that
Chris@16 443 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 444 //!
Chris@16 445 //! <b>Effects</b>: Erases all the elements that have the same hash and
Chris@16 446 //! compare equal with the given key.
Chris@16 447 //!
Chris@16 448 //! <b>Returns</b>: The number of erased elements.
Chris@16 449 //!
Chris@16 450 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 451 //! Worst case O(this->size()).
Chris@16 452 //!
Chris@16 453 //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee.
Chris@16 454 //!
Chris@16 455 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 456 //! to the erased elements. No destructors are called.
Chris@16 457 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 458 size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 459 { return table_type::erase(key, hash_func, equal_func); }
Chris@16 460
Chris@16 461 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 462 //!
Chris@16 463 //! <b>Effects</b>: Erases the element pointed to by i.
Chris@16 464 //! Disposer::operator()(pointer) is called for the removed element.
Chris@16 465 //!
Chris@16 466 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 467 //!
Chris@16 468 //! <b>Throws</b>: Nothing.
Chris@16 469 //!
Chris@16 470 //! <b>Note</b>: Invalidates the iterators
Chris@16 471 //! to the erased elements.
Chris@16 472 template<class Disposer>
Chris@16 473 void erase_and_dispose(const_iterator i, Disposer disposer
Chris@16 474 /// @cond
Chris@16 475 , typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
Chris@16 476 /// @endcond
Chris@16 477 )
Chris@16 478 { table_type::erase_and_dispose(i, disposer); }
Chris@16 479
Chris@16 480 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 481 //!
Chris@16 482 //! <b>Effects</b>: Erases the range pointed to by b end e.
Chris@16 483 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 484 //!
Chris@16 485 //! <b>Complexity</b>: Average case O(std::distance(b, e)),
Chris@16 486 //! worst case O(this->size()).
Chris@16 487 //!
Chris@16 488 //! <b>Throws</b>: Nothing.
Chris@16 489 //!
Chris@16 490 //! <b>Note</b>: Invalidates the iterators
Chris@16 491 //! to the erased elements.
Chris@16 492 template<class Disposer>
Chris@16 493 void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
Chris@16 494 { table_type::erase_and_dispose(b, e, disposer); }
Chris@16 495
Chris@16 496 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 497 //!
Chris@16 498 //! <b>Effects</b>: Erases all the elements with the given value.
Chris@16 499 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 500 //!
Chris@16 501 //! <b>Returns</b>: The number of erased elements.
Chris@16 502 //!
Chris@16 503 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 504 //! Worst case O(this->size()).
Chris@16 505 //!
Chris@16 506 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 507 //!
Chris@16 508 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 509 //! to the erased elements. No destructors are called.
Chris@16 510 template<class Disposer>
Chris@16 511 size_type erase_and_dispose(const_reference value, Disposer disposer)
Chris@16 512 { return table_type::erase_and_dispose(value, disposer); }
Chris@16 513
Chris@16 514 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 515 //!
Chris@16 516 //! <b>Effects</b>: Erases all the elements with the given key.
Chris@16 517 //! according to the comparison functor "equal_func".
Chris@16 518 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 519 //!
Chris@16 520 //! <b>Returns</b>: The number of erased elements.
Chris@16 521 //!
Chris@16 522 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 523 //! Worst case O(this->size()).
Chris@16 524 //!
Chris@16 525 //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee.
Chris@16 526 //!
Chris@16 527 //! <b>Note</b>: Invalidates the iterators
Chris@16 528 //! to the erased elements.
Chris@16 529 template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer>
Chris@16 530 size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func, Disposer disposer)
Chris@16 531 { return table_type::erase_and_dispose(key, hash_func, equal_func, disposer); }
Chris@16 532
Chris@16 533 //! <b>Effects</b>: Erases all of the elements.
Chris@16 534 //!
Chris@16 535 //! <b>Complexity</b>: Linear to the number of elements on the container.
Chris@16 536 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
Chris@16 537 //!
Chris@16 538 //! <b>Throws</b>: Nothing.
Chris@16 539 //!
Chris@16 540 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 541 //! to the erased elements. No destructors are called.
Chris@16 542 void clear()
Chris@16 543 { return table_type::clear(); }
Chris@16 544
Chris@16 545 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 546 //!
Chris@16 547 //! <b>Effects</b>: Erases all of the elements.
Chris@16 548 //!
Chris@16 549 //! <b>Complexity</b>: Linear to the number of elements on the container.
Chris@16 550 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 551 //!
Chris@16 552 //! <b>Throws</b>: Nothing.
Chris@16 553 //!
Chris@16 554 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 555 //! to the erased elements. No destructors are called.
Chris@16 556 template<class Disposer>
Chris@16 557 void clear_and_dispose(Disposer disposer)
Chris@16 558 { return table_type::clear_and_dispose(disposer); }
Chris@16 559
Chris@16 560 //! <b>Effects</b>: Returns the number of contained elements with the given value
Chris@16 561 //!
Chris@16 562 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 563 //!
Chris@16 564 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 565 size_type count(const_reference value) const
Chris@16 566 { return table_type::find(value) != end(); }
Chris@16 567
Chris@16 568 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 569 //! the same hash values as the stored hasher. The difference is that
Chris@16 570 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 571 //!
Chris@16 572 //! "equal_func" must be a equality function that induces
Chris@16 573 //! the same equality as key_equal. The difference is that
Chris@16 574 //! "equal_func" compares an arbitrary key with the contained values.
Chris@16 575 //!
Chris@16 576 //! <b>Effects</b>: Returns the number of contained elements with the given key
Chris@16 577 //!
Chris@16 578 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 579 //!
Chris@16 580 //! <b>Throws</b>: If hash_func or equal_func throw.
Chris@16 581 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 582 size_type count(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 583 { return table_type::find(key, hash_func, equal_func) != end(); }
Chris@16 584
Chris@16 585 //! <b>Effects</b>: Finds an iterator to the first element is equal to
Chris@16 586 //! "value" or end() if that element does not exist.
Chris@16 587 //!
Chris@16 588 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 589 //!
Chris@16 590 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 591 iterator find(const_reference value)
Chris@16 592 { return table_type::find(value); }
Chris@16 593
Chris@16 594 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 595 //! the same hash values as the stored hasher. The difference is that
Chris@16 596 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 597 //!
Chris@16 598 //! "equal_func" must be a equality function that induces
Chris@16 599 //! the same equality as key_equal. The difference is that
Chris@16 600 //! "equal_func" compares an arbitrary key with the contained values.
Chris@16 601 //!
Chris@16 602 //! <b>Effects</b>: Finds an iterator to the first element whose key is
Chris@16 603 //! "key" according to the given hasher and equality functor or end() if
Chris@16 604 //! that element does not exist.
Chris@16 605 //!
Chris@16 606 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 607 //!
Chris@16 608 //! <b>Throws</b>: If hash_func or equal_func throw.
Chris@16 609 //!
Chris@16 610 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 611 //! is expensive and the value_type can be compared with a cheaper
Chris@16 612 //! key type. Usually this key is part of the value_type.
Chris@16 613 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 614 iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 615 { return table_type::find(key, hash_func, equal_func); }
Chris@16 616
Chris@16 617 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
Chris@16 618 //! "key" or end() if that element does not exist.
Chris@16 619 //!
Chris@16 620 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 621 //!
Chris@16 622 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 623 const_iterator find(const_reference value) const
Chris@16 624 { return table_type::find(value); }
Chris@16 625
Chris@16 626 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 627 //! the same hash values as the stored hasher. The difference is that
Chris@16 628 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 629 //!
Chris@16 630 //! "equal_func" must be a equality function that induces
Chris@16 631 //! the same equality as key_equal. The difference is that
Chris@16 632 //! "equal_func" compares an arbitrary key with the contained values.
Chris@16 633 //!
Chris@16 634 //! <b>Effects</b>: Finds an iterator to the first element whose key is
Chris@16 635 //! "key" according to the given hasher and equality functor or end() if
Chris@16 636 //! that element does not exist.
Chris@16 637 //!
Chris@16 638 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 639 //!
Chris@16 640 //! <b>Throws</b>: If hash_func or equal_func throw.
Chris@16 641 //!
Chris@16 642 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 643 //! is expensive and the value_type can be compared with a cheaper
Chris@16 644 //! key type. Usually this key is part of the value_type.
Chris@16 645 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 646 const_iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 647 { return table_type::find(key, hash_func, equal_func); }
Chris@16 648
Chris@16 649 //! <b>Effects</b>: Returns a range containing all elements with values equivalent
Chris@16 650 //! to value. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 651 //! elements exist.
Chris@16 652 //!
Chris@16 653 //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
Chris@16 654 //!
Chris@16 655 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 656 std::pair<iterator,iterator> equal_range(const_reference value)
Chris@16 657 { return table_type::equal_range(value); }
Chris@16 658
Chris@16 659 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 660 //! the same hash values as the stored hasher. The difference is that
Chris@16 661 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 662 //!
Chris@16 663 //! "equal_func" must be a equality function that induces
Chris@16 664 //! the same equality as key_equal. The difference is that
Chris@16 665 //! "equal_func" compares an arbitrary key with the contained values.
Chris@16 666 //!
Chris@16 667 //! <b>Effects</b>: Returns a range containing all elements with equivalent
Chris@16 668 //! keys. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 669 //! elements exist.
Chris@16 670 //!
Chris@16 671 //! <b>Complexity</b>: Average case O(this->count(key, hash_func, hash_func)).
Chris@16 672 //! Worst case O(this->size()).
Chris@16 673 //!
Chris@16 674 //! <b>Throws</b>: If hash_func or the equal_func throw.
Chris@16 675 //!
Chris@16 676 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 677 //! is expensive and the value_type can be compared with a cheaper
Chris@16 678 //! key type. Usually this key is part of the value_type.
Chris@16 679 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 680 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 681 { return table_type::equal_range(key, hash_func, equal_func); }
Chris@16 682
Chris@16 683 //! <b>Effects</b>: Returns a range containing all elements with values equivalent
Chris@16 684 //! to value. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 685 //! elements exist.
Chris@16 686 //!
Chris@16 687 //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
Chris@16 688 //!
Chris@16 689 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 690 std::pair<const_iterator, const_iterator>
Chris@16 691 equal_range(const_reference value) const
Chris@16 692 { return table_type::equal_range(value); }
Chris@16 693
Chris@16 694 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 695 //! the same hash values as the stored hasher. The difference is that
Chris@16 696 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 697 //!
Chris@16 698 //! "equal_func" must be a equality function that induces
Chris@16 699 //! the same equality as key_equal. The difference is that
Chris@16 700 //! "equal_func" compares an arbitrary key with the contained values.
Chris@16 701 //!
Chris@16 702 //! <b>Effects</b>: Returns a range containing all elements with equivalent
Chris@16 703 //! keys. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 704 //! elements exist.
Chris@16 705 //!
Chris@16 706 //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)).
Chris@16 707 //! Worst case O(this->size()).
Chris@16 708 //!
Chris@16 709 //! <b>Throws</b>: If the hash_func or equal_func throw.
Chris@16 710 //!
Chris@16 711 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 712 //! is expensive and the value_type can be compared with a cheaper
Chris@16 713 //! key type. Usually this key is part of the value_type.
Chris@16 714 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 715 std::pair<const_iterator, const_iterator>
Chris@16 716 equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 717 { return table_type::equal_range(key, hash_func, equal_func); }
Chris@16 718
Chris@16 719 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 720 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 721 //!
Chris@16 722 //! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_set
Chris@16 723 //! that points to the value
Chris@16 724 //!
Chris@16 725 //! <b>Complexity</b>: Constant.
Chris@16 726 //!
Chris@16 727 //! <b>Throws</b>: If the internal hash function throws.
Chris@16 728 iterator iterator_to(reference value)
Chris@16 729 { return table_type::iterator_to(value); }
Chris@16 730
Chris@16 731 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 732 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 733 //!
Chris@16 734 //! <b>Effects</b>: Returns: a valid const_iterator belonging to the
Chris@16 735 //! unordered_set that points to the value
Chris@16 736 //!
Chris@16 737 //! <b>Complexity</b>: Constant.
Chris@16 738 //!
Chris@16 739 //! <b>Throws</b>: If the internal hash function throws.
Chris@16 740 const_iterator iterator_to(const_reference value) const
Chris@16 741 { return table_type::iterator_to(value); }
Chris@16 742
Chris@16 743 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 744 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 745 //!
Chris@16 746 //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
Chris@16 747 //! that points to the value
Chris@16 748 //!
Chris@16 749 //! <b>Complexity</b>: Constant.
Chris@16 750 //!
Chris@16 751 //! <b>Throws</b>: Nothing.
Chris@16 752 //!
Chris@16 753 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
Chris@16 754 //! is stateless.
Chris@16 755 static local_iterator s_local_iterator_to(reference value)
Chris@16 756 { return table_type::s_local_iterator_to(value); }
Chris@16 757
Chris@16 758 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 759 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 760 //!
Chris@16 761 //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
Chris@16 762 //! the unordered_set that points to the value
Chris@16 763 //!
Chris@16 764 //! <b>Complexity</b>: Constant.
Chris@16 765 //!
Chris@16 766 //! <b>Throws</b>: Nothing.
Chris@16 767 //!
Chris@16 768 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
Chris@16 769 //! is stateless.
Chris@16 770 static const_local_iterator s_local_iterator_to(const_reference value)
Chris@16 771 { return table_type::s_local_iterator_to(value); }
Chris@16 772
Chris@16 773 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 774 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 775 //!
Chris@16 776 //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
Chris@16 777 //! that points to the value
Chris@16 778 //!
Chris@16 779 //! <b>Complexity</b>: Constant.
Chris@16 780 //!
Chris@16 781 //! <b>Throws</b>: Nothing.
Chris@16 782 local_iterator local_iterator_to(reference value)
Chris@16 783 { return table_type::local_iterator_to(value); }
Chris@16 784
Chris@16 785 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 786 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 787 //!
Chris@16 788 //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
Chris@16 789 //! the unordered_set that points to the value
Chris@16 790 //!
Chris@16 791 //! <b>Complexity</b>: Constant.
Chris@16 792 //!
Chris@16 793 //! <b>Throws</b>: Nothing.
Chris@16 794 const_local_iterator local_iterator_to(const_reference value) const
Chris@16 795 { return table_type::local_iterator_to(value); }
Chris@16 796
Chris@16 797 //! <b>Effects</b>: Returns the number of buckets passed in the constructor
Chris@16 798 //! or the last rehash function.
Chris@16 799 //!
Chris@16 800 //! <b>Complexity</b>: Constant.
Chris@16 801 //!
Chris@16 802 //! <b>Throws</b>: Nothing.
Chris@16 803 size_type bucket_count() const
Chris@16 804 { return table_type::bucket_count(); }
Chris@16 805
Chris@16 806 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 807 //!
Chris@16 808 //! <b>Effects</b>: Returns the number of elements in the nth bucket.
Chris@16 809 //!
Chris@16 810 //! <b>Complexity</b>: Constant.
Chris@16 811 //!
Chris@16 812 //! <b>Throws</b>: Nothing.
Chris@16 813 size_type bucket_size(size_type n) const
Chris@16 814 { return table_type::bucket_size(n); }
Chris@16 815
Chris@16 816 //! <b>Effects</b>: Returns the index of the bucket in which elements
Chris@16 817 //! with keys equivalent to k would be found, if any such element existed.
Chris@16 818 //!
Chris@16 819 //! <b>Complexity</b>: Constant.
Chris@16 820 //!
Chris@16 821 //! <b>Throws</b>: If the hash functor throws.
Chris@16 822 //!
Chris@16 823 //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
Chris@16 824 size_type bucket(const value_type& k) const
Chris@16 825 { return table_type::bucket(k); }
Chris@16 826
Chris@16 827 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 828 //! the same hash values as the stored hasher. The difference is that
Chris@16 829 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 830 //!
Chris@16 831 //! <b>Effects</b>: Returns the index of the bucket in which elements
Chris@16 832 //! with keys equivalent to k would be found, if any such element existed.
Chris@16 833 //!
Chris@16 834 //! <b>Complexity</b>: Constant.
Chris@16 835 //!
Chris@16 836 //! <b>Throws</b>: If hash_func throws.
Chris@16 837 //!
Chris@16 838 //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
Chris@16 839 template<class KeyType, class KeyHasher>
Chris@16 840 size_type bucket(const KeyType& k, KeyHasher hash_func) const
Chris@16 841 { return table_type::bucket(k, hash_func); }
Chris@16 842
Chris@16 843 //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor
Chris@16 844 //! or the last rehash function.
Chris@16 845 //!
Chris@16 846 //! <b>Complexity</b>: Constant.
Chris@16 847 //!
Chris@16 848 //! <b>Throws</b>: Nothing.
Chris@16 849 bucket_ptr bucket_pointer() const
Chris@16 850 { return table_type::bucket_pointer(); }
Chris@16 851
Chris@16 852 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 853 //!
Chris@16 854 //! <b>Effects</b>: Returns a local_iterator pointing to the beginning
Chris@16 855 //! of the sequence stored in the bucket n.
Chris@16 856 //!
Chris@16 857 //! <b>Complexity</b>: Constant.
Chris@16 858 //!
Chris@16 859 //! <b>Throws</b>: Nothing.
Chris@16 860 //!
Chris@16 861 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 862 //! containing all of the elements in the nth bucket.
Chris@16 863 local_iterator begin(size_type n)
Chris@16 864 { return table_type::begin(n); }
Chris@16 865
Chris@16 866 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 867 //!
Chris@16 868 //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
Chris@16 869 //! of the sequence stored in the bucket n.
Chris@16 870 //!
Chris@16 871 //! <b>Complexity</b>: Constant.
Chris@16 872 //!
Chris@16 873 //! <b>Throws</b>: Nothing.
Chris@16 874 //!
Chris@16 875 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 876 //! containing all of the elements in the nth bucket.
Chris@16 877 const_local_iterator begin(size_type n) const
Chris@16 878 { return table_type::begin(n); }
Chris@16 879
Chris@16 880 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 881 //!
Chris@16 882 //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
Chris@16 883 //! of the sequence stored in the bucket n.
Chris@16 884 //!
Chris@16 885 //! <b>Complexity</b>: Constant.
Chris@16 886 //!
Chris@16 887 //! <b>Throws</b>: Nothing.
Chris@16 888 //!
Chris@16 889 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 890 //! containing all of the elements in the nth bucket.
Chris@16 891 const_local_iterator cbegin(size_type n) const
Chris@16 892 { return table_type::cbegin(n); }
Chris@16 893
Chris@16 894 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 895 //!
Chris@16 896 //! <b>Effects</b>: Returns a local_iterator pointing to the end
Chris@16 897 //! of the sequence stored in the bucket n.
Chris@16 898 //!
Chris@16 899 //! <b>Complexity</b>: Constant.
Chris@16 900 //!
Chris@16 901 //! <b>Throws</b>: Nothing.
Chris@16 902 //!
Chris@16 903 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 904 //! containing all of the elements in the nth bucket.
Chris@16 905 local_iterator end(size_type n)
Chris@16 906 { return table_type::end(n); }
Chris@16 907
Chris@16 908 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 909 //!
Chris@16 910 //! <b>Effects</b>: Returns a const_local_iterator pointing to the end
Chris@16 911 //! of the sequence stored in the bucket n.
Chris@16 912 //!
Chris@16 913 //! <b>Complexity</b>: Constant.
Chris@16 914 //!
Chris@16 915 //! <b>Throws</b>: Nothing.
Chris@16 916 //!
Chris@16 917 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 918 //! containing all of the elements in the nth bucket.
Chris@16 919 const_local_iterator end(size_type n) const
Chris@16 920 { return table_type::end(n); }
Chris@16 921
Chris@16 922 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 923 //!
Chris@16 924 //! <b>Effects</b>: Returns a const_local_iterator pointing to the end
Chris@16 925 //! of the sequence stored in the bucket n.
Chris@16 926 //!
Chris@16 927 //! <b>Complexity</b>: Constant.
Chris@16 928 //!
Chris@16 929 //! <b>Throws</b>: Nothing.
Chris@16 930 //!
Chris@16 931 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 932 //! containing all of the elements in the nth bucket.
Chris@16 933 const_local_iterator cend(size_type n) const
Chris@16 934 { return table_type::cend(n); }
Chris@16 935
Chris@16 936 //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array
Chris@16 937 //! or the same as the old bucket array. new_size is the length of the
Chris@16 938 //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer()
Chris@16 939 //! n can be bigger or smaller than this->bucket_count().
Chris@16 940 //!
Chris@16 941 //! <b>Effects</b>: Updates the internal reference with the new bucket erases
Chris@16 942 //! the values from the old bucket and inserts then in the new one.
Chris@16 943 //!
Chris@16 944 //! If store_hash option is true, this method does not use the hash function.
Chris@16 945 //!
Chris@16 946 //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic.
Chris@16 947 //!
Chris@16 948 //! <b>Throws</b>: If the hasher functor throws. Basic guarantee.
Chris@16 949 void rehash(const bucket_traits &new_bucket_traits)
Chris@16 950 { table_type::rehash(new_bucket_traits); }
Chris@16 951
Chris@16 952 //! <b>Requires</b>:
Chris@16 953 //!
Chris@16 954 //! <b>Effects</b>:
Chris@16 955 //!
Chris@16 956 //! <b>Complexity</b>:
Chris@16 957 //!
Chris@16 958 //! <b>Throws</b>:
Chris@16 959 //!
Chris@16 960 //! <b>Note</b>: this method is only available if incremental<true> option is activated.
Chris@16 961 bool incremental_rehash(bool grow = true)
Chris@16 962 { return table_type::incremental_rehash(grow); }
Chris@16 963
Chris@16 964 //! <b>Note</b>: this method is only available if incremental<true> option is activated.
Chris@16 965 bool incremental_rehash(const bucket_traits &new_bucket_traits)
Chris@16 966 { return table_type::incremental_rehash(new_bucket_traits); }
Chris@16 967
Chris@16 968 //! <b>Requires</b>:
Chris@16 969 //!
Chris@16 970 //! <b>Effects</b>:
Chris@16 971 //!
Chris@16 972 //! <b>Complexity</b>:
Chris@16 973 //!
Chris@16 974 //! <b>Throws</b>:
Chris@16 975 size_type split_count() const
Chris@16 976 { return table_type::split_count(); }
Chris@16 977
Chris@16 978 //! <b>Effects</b>: Returns the nearest new bucket count optimized for
Chris@16 979 //! the container that is bigger than n. This suggestion can be used
Chris@16 980 //! to create bucket arrays with a size that will usually improve
Chris@16 981 //! container's performance. If such value does not exist, the
Chris@16 982 //! higher possible value is returned.
Chris@16 983 //!
Chris@16 984 //! <b>Complexity</b>: Amortized constant time.
Chris@16 985 //!
Chris@16 986 //! <b>Throws</b>: Nothing.
Chris@16 987 static size_type suggested_upper_bucket_count(size_type n)
Chris@16 988 { return table_type::suggested_upper_bucket_count(n); }
Chris@16 989
Chris@16 990 //! <b>Effects</b>: Returns the nearest new bucket count optimized for
Chris@16 991 //! the container that is smaller than n. This suggestion can be used
Chris@16 992 //! to create bucket arrays with a size that will usually improve
Chris@16 993 //! container's performance. If such value does not exist, the
Chris@16 994 //! lower possible value is returned.
Chris@16 995 //!
Chris@16 996 //! <b>Complexity</b>: Amortized constant time.
Chris@16 997 //!
Chris@16 998 //! <b>Throws</b>: Nothing.
Chris@16 999 static size_type suggested_lower_bucket_count(size_type n)
Chris@16 1000 { return table_type::suggested_lower_bucket_count(n); }
Chris@16 1001
Chris@16 1002 #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 1003 };
Chris@16 1004
Chris@16 1005 //! Helper metafunction to define an \c unordered_set that yields to the same type when the
Chris@16 1006 //! same options (either explicitly or implicitly) are used.
Chris@16 1007 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 1008 template<class T, class ...Options>
Chris@16 1009 #else
Chris@16 1010 template<class T, class O1 = void, class O2 = void
Chris@16 1011 , class O3 = void, class O4 = void
Chris@16 1012 , class O5 = void, class O6 = void
Chris@16 1013 , class O7 = void, class O8 = void
Chris@16 1014 , class O9 = void, class O10= void
Chris@16 1015 >
Chris@16 1016 #endif
Chris@16 1017 struct make_unordered_set
Chris@16 1018 {
Chris@16 1019 /// @cond
Chris@16 1020 typedef typename pack_options
Chris@16 1021 < hashtable_defaults,
Chris@16 1022 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 1023 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 1024 #else
Chris@16 1025 Options...
Chris@16 1026 #endif
Chris@16 1027 >::type packed_options;
Chris@16 1028
Chris@16 1029 typedef typename detail::get_value_traits
Chris@16 1030 <T, typename packed_options::proto_value_traits>::type value_traits;
Chris@16 1031
Chris@16 1032 typedef typename make_real_bucket_traits
Chris@16 1033 <T, true, packed_options>::type real_bucket_traits;
Chris@16 1034
Chris@16 1035 typedef unordered_set_impl
Chris@16 1036 < value_traits
Chris@16 1037 , typename packed_options::hash
Chris@16 1038 , typename packed_options::equal
Chris@16 1039 , typename packed_options::size_type
Chris@16 1040 , real_bucket_traits
Chris@16 1041 , (std::size_t(true)*hash_bool_flags::unique_keys_pos)
Chris@16 1042 | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
Chris@16 1043 | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
Chris@16 1044 | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
Chris@16 1045 | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
Chris@16 1046 | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
Chris@16 1047 > implementation_defined;
Chris@16 1048
Chris@16 1049 /// @endcond
Chris@16 1050 typedef implementation_defined type;
Chris@16 1051 };
Chris@16 1052
Chris@16 1053 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 1054
Chris@16 1055 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 1056 template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
Chris@16 1057 #else
Chris@16 1058 template<class T, class ...Options>
Chris@16 1059 #endif
Chris@16 1060 class unordered_set
Chris@16 1061 : public make_unordered_set<T,
Chris@16 1062 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 1063 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 1064 #else
Chris@16 1065 Options...
Chris@16 1066 #endif
Chris@16 1067 >::type
Chris@16 1068 {
Chris@16 1069 typedef typename make_unordered_set
Chris@16 1070 <T,
Chris@16 1071 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 1072 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 1073 #else
Chris@16 1074 Options...
Chris@16 1075 #endif
Chris@16 1076 >::type Base;
Chris@16 1077
Chris@16 1078 //Assert if passed value traits are compatible with the type
Chris@16 1079 BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
Chris@16 1080 BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set)
Chris@16 1081
Chris@16 1082 public:
Chris@16 1083 typedef typename Base::value_traits value_traits;
Chris@16 1084 typedef typename Base::bucket_traits bucket_traits;
Chris@16 1085 typedef typename Base::iterator iterator;
Chris@16 1086 typedef typename Base::const_iterator const_iterator;
Chris@16 1087 typedef typename Base::bucket_ptr bucket_ptr;
Chris@16 1088 typedef typename Base::size_type size_type;
Chris@16 1089 typedef typename Base::hasher hasher;
Chris@16 1090 typedef typename Base::key_equal key_equal;
Chris@16 1091
Chris@16 1092 explicit unordered_set ( const bucket_traits &b_traits
Chris@16 1093 , const hasher & hash_func = hasher()
Chris@16 1094 , const key_equal &equal_func = key_equal()
Chris@16 1095 , const value_traits &v_traits = value_traits())
Chris@16 1096 : Base(b_traits, hash_func, equal_func, v_traits)
Chris@16 1097 {}
Chris@16 1098
Chris@16 1099 template<class Iterator>
Chris@16 1100 unordered_set ( Iterator b
Chris@16 1101 , Iterator e
Chris@16 1102 , const bucket_traits &b_traits
Chris@16 1103 , const hasher & hash_func = hasher()
Chris@16 1104 , const key_equal &equal_func = key_equal()
Chris@16 1105 , const value_traits &v_traits = value_traits())
Chris@16 1106 : Base(b, e, b_traits, hash_func, equal_func, v_traits)
Chris@16 1107 {}
Chris@16 1108
Chris@16 1109 unordered_set(BOOST_RV_REF(unordered_set) x)
Chris@16 1110 : Base(::boost::move(static_cast<Base&>(x)))
Chris@16 1111 {}
Chris@16 1112
Chris@16 1113 unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
Chris@16 1114 { return static_cast<unordered_set&>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
Chris@16 1115 };
Chris@16 1116
Chris@16 1117 #endif
Chris@16 1118
Chris@16 1119
Chris@16 1120 //! The class template unordered_multiset is an intrusive container, that mimics most of
Chris@16 1121 //! the interface of std::tr1::unordered_multiset as described in the C++ TR1.
Chris@16 1122 //!
Chris@16 1123 //! unordered_multiset is a semi-intrusive container: each object to be stored in the
Chris@16 1124 //! container must contain a proper hook, but the container also needs
Chris@16 1125 //! additional auxiliary memory to work: unordered_multiset needs a pointer to an array
Chris@16 1126 //! of type `bucket_type` to be passed in the constructor. This bucket array must
Chris@16 1127 //! have at least the same lifetime as the container. This makes the use of
Chris@16 1128 //! unordered_multiset more complicated than purely intrusive containers.
Chris@16 1129 //! `bucket_type` is default-constructible, copyable and assignable
Chris@16 1130 //!
Chris@16 1131 //! The template parameter \c T is the type to be managed by the container.
Chris@16 1132 //! The user can specify additional options and if no options are provided
Chris@16 1133 //! default options are used.
Chris@16 1134 //!
Chris@16 1135 //! The container supports the following options:
Chris@16 1136 //! \c base_hook<>/member_hook<>/value_traits<>,
Chris@16 1137 //! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
Chris@16 1138 //! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>.
Chris@16 1139 //!
Chris@16 1140 //! unordered_multiset only provides forward iterators but it provides 4 iterator types:
Chris@16 1141 //! iterator and const_iterator to navigate through the whole container and
Chris@16 1142 //! local_iterator and const_local_iterator to navigate through the values
Chris@16 1143 //! stored in a single bucket. Local iterators are faster and smaller.
Chris@16 1144 //!
Chris@16 1145 //! It's not recommended to use non constant-time size unordered_multisets because several
Chris@16 1146 //! key functions, like "empty()", become non-constant time functions. Non
Chris@16 1147 //! constant-time size unordered_multisets are mainly provided to support auto-unlink hooks.
Chris@16 1148 //!
Chris@16 1149 //! unordered_multiset, unlike std::unordered_set, does not make automatic rehashings nor
Chris@16 1150 //! offers functions related to a load factor. Rehashing can be explicitly requested
Chris@16 1151 //! and the user must provide a new bucket array that will be used from that moment.
Chris@16 1152 //!
Chris@16 1153 //! Since no automatic rehashing is done, iterators are never invalidated when
Chris@16 1154 //! inserting or erasing elements. Iterators are only invalidated when rehasing.
Chris@16 1155 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
Chris@16 1156 template<class T, class ...Options>
Chris@16 1157 #else
Chris@16 1158 template<class ValueTraits, class Hash, class Equal, class SizeType, class BucketTraits, std::size_t BoolFlags>
Chris@16 1159 #endif
Chris@16 1160 class unordered_multiset_impl
Chris@16 1161 : public hashtable_impl<ValueTraits, Hash, Equal, SizeType, BucketTraits, BoolFlags>
Chris@16 1162 {
Chris@16 1163 /// @cond
Chris@16 1164 private:
Chris@16 1165 typedef hashtable_impl<ValueTraits, Hash, Equal, SizeType, BucketTraits, BoolFlags> table_type;
Chris@16 1166 /// @endcond
Chris@16 1167
Chris@16 1168 //Movable
Chris@16 1169 BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset_impl)
Chris@16 1170
Chris@16 1171 typedef table_type implementation_defined;
Chris@16 1172
Chris@16 1173 public:
Chris@16 1174 typedef typename implementation_defined::value_type value_type;
Chris@16 1175 typedef typename implementation_defined::value_traits value_traits;
Chris@16 1176 typedef typename implementation_defined::bucket_traits bucket_traits;
Chris@16 1177 typedef typename implementation_defined::pointer pointer;
Chris@16 1178 typedef typename implementation_defined::const_pointer const_pointer;
Chris@16 1179 typedef typename implementation_defined::reference reference;
Chris@16 1180 typedef typename implementation_defined::const_reference const_reference;
Chris@16 1181 typedef typename implementation_defined::difference_type difference_type;
Chris@16 1182 typedef typename implementation_defined::size_type size_type;
Chris@16 1183 typedef typename implementation_defined::key_type key_type;
Chris@16 1184 typedef typename implementation_defined::key_equal key_equal;
Chris@16 1185 typedef typename implementation_defined::hasher hasher;
Chris@16 1186 typedef typename implementation_defined::bucket_type bucket_type;
Chris@16 1187 typedef typename implementation_defined::bucket_ptr bucket_ptr;
Chris@16 1188 typedef typename implementation_defined::iterator iterator;
Chris@16 1189 typedef typename implementation_defined::const_iterator const_iterator;
Chris@16 1190 typedef typename implementation_defined::insert_commit_data insert_commit_data;
Chris@16 1191 typedef typename implementation_defined::local_iterator local_iterator;
Chris@16 1192 typedef typename implementation_defined::const_local_iterator const_local_iterator;
Chris@16 1193 typedef typename implementation_defined::node_traits node_traits;
Chris@16 1194 typedef typename implementation_defined::node node;
Chris@16 1195 typedef typename implementation_defined::node_ptr node_ptr;
Chris@16 1196 typedef typename implementation_defined::const_node_ptr const_node_ptr;
Chris@16 1197 typedef typename implementation_defined::node_algorithms node_algorithms;
Chris@16 1198
Chris@16 1199 public:
Chris@16 1200
Chris@16 1201 //! <b>Requires</b>: buckets must not be being used by any other resource.
Chris@16 1202 //!
Chris@16 1203 //! <b>Effects</b>: Constructs an empty unordered_multiset, storing a reference
Chris@16 1204 //! to the bucket array and copies of the hasher and equal functors.
Chris@16 1205 //!
Chris@16 1206 //! <b>Complexity</b>: Constant.
Chris@16 1207 //!
Chris@16 1208 //! <b>Throws</b>: If value_traits::node_traits::node
Chris@16 1209 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
Chris@16 1210 //! or the copy constructor or invocation of Hash or Equal throws.
Chris@16 1211 //!
Chris@16 1212 //! <b>Notes</b>: buckets array must be disposed only after
Chris@16 1213 //! *this is disposed.
Chris@16 1214 explicit unordered_multiset_impl ( const bucket_traits &b_traits
Chris@16 1215 , const hasher & hash_func = hasher()
Chris@16 1216 , const key_equal &equal_func = key_equal()
Chris@16 1217 , const value_traits &v_traits = value_traits())
Chris@16 1218 : table_type(b_traits, hash_func, equal_func, v_traits)
Chris@16 1219 {}
Chris@16 1220
Chris@16 1221 //! <b>Requires</b>: buckets must not be being used by any other resource
Chris@16 1222 //! and Dereferencing iterator must yield an lvalue of type value_type.
Chris@16 1223 //!
Chris@16 1224 //! <b>Effects</b>: Constructs an empty unordered_multiset and inserts elements from
Chris@16 1225 //! [b, e).
Chris@16 1226 //!
Chris@16 1227 //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N)
Chris@16 1228 //! (with a good hash function and with buckets_len >= N),worst case O(N2).
Chris@16 1229 //!
Chris@16 1230 //! <b>Throws</b>: If value_traits::node_traits::node
Chris@16 1231 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
Chris@16 1232 //! or the copy constructor or invocation of hasher or key_equal throws.
Chris@16 1233 //!
Chris@16 1234 //! <b>Notes</b>: buckets array must be disposed only after
Chris@16 1235 //! *this is disposed.
Chris@16 1236 template<class Iterator>
Chris@16 1237 unordered_multiset_impl ( Iterator b
Chris@16 1238 , Iterator e
Chris@16 1239 , const bucket_traits &b_traits
Chris@16 1240 , const hasher & hash_func = hasher()
Chris@16 1241 , const key_equal &equal_func = key_equal()
Chris@16 1242 , const value_traits &v_traits = value_traits())
Chris@16 1243 : table_type(b_traits, hash_func, equal_func, v_traits)
Chris@16 1244 { table_type::insert_equal(b, e); }
Chris@16 1245
Chris@16 1246 //! <b>Effects</b>: to-do
Chris@16 1247 //!
Chris@16 1248 unordered_multiset_impl(BOOST_RV_REF(unordered_multiset_impl) x)
Chris@16 1249 : table_type(::boost::move(static_cast<table_type&>(x)))
Chris@16 1250 {}
Chris@16 1251
Chris@16 1252 //! <b>Effects</b>: to-do
Chris@16 1253 //!
Chris@16 1254 unordered_multiset_impl& operator=(BOOST_RV_REF(unordered_multiset_impl) x)
Chris@16 1255 { return static_cast<unordered_multiset_impl&>(table_type::operator=(::boost::move(static_cast<table_type&>(x)))); }
Chris@16 1256
Chris@16 1257 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 1258
Chris@16 1259 //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_multiset
Chris@16 1260 //! are not deleted (i.e. no destructors are called).
Chris@16 1261 //!
Chris@16 1262 //! <b>Complexity</b>: Linear to the number of elements in the unordered_multiset, if
Chris@16 1263 //! it's a safe-mode or auto-unlink value. Otherwise constant.
Chris@16 1264 //!
Chris@16 1265 //! <b>Throws</b>: Nothing.
Chris@16 1266 ~unordered_multiset_impl()
Chris@16 1267 {}
Chris@16 1268
Chris@16 1269 //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_multiset.
Chris@16 1270 //!
Chris@16 1271 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 1272 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 1273 //!
Chris@16 1274 //! <b>Throws</b>: Nothing.
Chris@16 1275 iterator begin()
Chris@16 1276 { return table_type::begin(); }
Chris@16 1277
Chris@16 1278 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning
Chris@16 1279 //! of the unordered_multiset.
Chris@16 1280 //!
Chris@16 1281 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 1282 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 1283 //!
Chris@16 1284 //! <b>Throws</b>: Nothing.
Chris@16 1285 const_iterator begin() const
Chris@16 1286 { return table_type::begin(); }
Chris@16 1287
Chris@16 1288 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning
Chris@16 1289 //! of the unordered_multiset.
Chris@16 1290 //!
Chris@16 1291 //! <b>Complexity</b>: Constant time if `cache_begin<>` is true. Amortized
Chris@16 1292 //! constant time with worst case (empty unordered_set) O(this->bucket_count())
Chris@16 1293 //!
Chris@16 1294 //! <b>Throws</b>: Nothing.
Chris@16 1295 const_iterator cbegin() const
Chris@16 1296 { return table_type::cbegin(); }
Chris@16 1297
Chris@16 1298 //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_multiset.
Chris@16 1299 //!
Chris@16 1300 //! <b>Complexity</b>: Constant.
Chris@16 1301 //!
Chris@16 1302 //! <b>Throws</b>: Nothing.
Chris@16 1303 iterator end()
Chris@16 1304 { return table_type::end(); }
Chris@16 1305
Chris@16 1306 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_multiset.
Chris@16 1307 //!
Chris@16 1308 //! <b>Complexity</b>: Constant.
Chris@16 1309 //!
Chris@16 1310 //! <b>Throws</b>: Nothing.
Chris@16 1311 const_iterator end() const
Chris@16 1312 { return table_type::end(); }
Chris@16 1313
Chris@16 1314 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_multiset.
Chris@16 1315 //!
Chris@16 1316 //! <b>Complexity</b>: Constant.
Chris@16 1317 //!
Chris@16 1318 //! <b>Throws</b>: Nothing.
Chris@16 1319 const_iterator cend() const
Chris@16 1320 { return table_type::cend(); }
Chris@16 1321
Chris@16 1322 //! <b>Effects</b>: Returns the hasher object used by the unordered_set.
Chris@16 1323 //!
Chris@16 1324 //! <b>Complexity</b>: Constant.
Chris@16 1325 //!
Chris@16 1326 //! <b>Throws</b>: If hasher copy-constructor throws.
Chris@16 1327 hasher hash_function() const
Chris@16 1328 { return table_type::hash_function(); }
Chris@16 1329
Chris@16 1330 //! <b>Effects</b>: Returns the key_equal object used by the unordered_multiset.
Chris@16 1331 //!
Chris@16 1332 //! <b>Complexity</b>: Constant.
Chris@16 1333 //!
Chris@16 1334 //! <b>Throws</b>: If key_equal copy-constructor throws.
Chris@16 1335 key_equal key_eq() const
Chris@16 1336 { return table_type::key_eq(); }
Chris@16 1337
Chris@16 1338 //! <b>Effects</b>: Returns true if the container is empty.
Chris@16 1339 //!
Chris@16 1340 //! <b>Complexity</b>: if constant-time size and cache_last options are disabled,
Chris@16 1341 //! average constant time (worst case, with empty() == true: O(this->bucket_count()).
Chris@16 1342 //! Otherwise constant.
Chris@16 1343 //!
Chris@16 1344 //! <b>Throws</b>: Nothing.
Chris@16 1345 bool empty() const
Chris@16 1346 { return table_type::empty(); }
Chris@16 1347
Chris@16 1348 //! <b>Effects</b>: Returns the number of elements stored in the unordered_multiset.
Chris@16 1349 //!
Chris@16 1350 //! <b>Complexity</b>: Linear to elements contained in *this if
Chris@16 1351 //! constant-time size option is disabled. Constant-time otherwise.
Chris@16 1352 //!
Chris@16 1353 //! <b>Throws</b>: Nothing.
Chris@16 1354 size_type size() const
Chris@16 1355 { return table_type::size(); }
Chris@16 1356
Chris@16 1357 //! <b>Requires</b>: the hasher and the equality function unqualified swap
Chris@16 1358 //! call should not throw.
Chris@16 1359 //!
Chris@16 1360 //! <b>Effects</b>: Swaps the contents of two unordered_multisets.
Chris@16 1361 //! Swaps also the contained bucket array and equality and hasher functors.
Chris@16 1362 //!
Chris@16 1363 //!
Chris@16 1364 //! <b>Complexity</b>: Constant.
Chris@16 1365 //!
Chris@16 1366 //! <b>Throws</b>: If the swap() call for the comparison or hash functors
Chris@16 1367 //! found using ADL throw. Basic guarantee.
Chris@16 1368 void swap(unordered_multiset_impl& other)
Chris@16 1369 { table_type::swap(other.table_); }
Chris@16 1370
Chris@16 1371 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1372 //! Cloner should yield to nodes that compare equal and produce the same
Chris@16 1373 //! hash than the original node.
Chris@16 1374 //!
Chris@16 1375 //! <b>Effects</b>: Erases all the elements from *this
Chris@16 1376 //! calling Disposer::operator()(pointer), clones all the
Chris@16 1377 //! elements from src calling Cloner::operator()(const_reference )
Chris@16 1378 //! and inserts them on *this. The hash function and the equality
Chris@16 1379 //! predicate are copied from the source.
Chris@16 1380 //!
Chris@16 1381 //! If store_hash option is true, this method does not use the hash function.
Chris@16 1382 //!
Chris@16 1383 //! If any operation throws, all cloned elements are unlinked and disposed
Chris@16 1384 //! calling Disposer::operator()(pointer).
Chris@16 1385 //!
Chris@16 1386 //! <b>Complexity</b>: Linear to erased plus inserted elements.
Chris@16 1387 //!
Chris@16 1388 //! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying
Chris@16 1389 //! throws. Basic guarantee.
Chris@16 1390 template <class Cloner, class Disposer>
Chris@16 1391 void clone_from(const unordered_multiset_impl &src, Cloner cloner, Disposer disposer)
Chris@16 1392 { table_type::clone_from(src.table_, cloner, disposer); }
Chris@16 1393
Chris@16 1394 #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 1395
Chris@16 1396 //! <b>Requires</b>: value must be an lvalue
Chris@16 1397 //!
Chris@16 1398 //! <b>Effects</b>: Inserts value into the unordered_multiset.
Chris@16 1399 //!
Chris@16 1400 //! <b>Returns</b>: An iterator to the new inserted value.
Chris@16 1401 //!
Chris@16 1402 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1403 //!
Chris@16 1404 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.
Chris@16 1405 //!
Chris@16 1406 //! <b>Note</b>: Does not affect the validity of iterators and references.
Chris@16 1407 //! No copy-constructors are called.
Chris@16 1408 iterator insert(reference value)
Chris@16 1409 { return table_type::insert_equal(value); }
Chris@16 1410
Chris@16 1411 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
Chris@16 1412 //! of type value_type.
Chris@16 1413 //!
Chris@16 1414 //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e).
Chris@16 1415 //!
Chris@16 1416 //! <b>Complexity</b>: Average case is O(N), where N is the
Chris@16 1417 //! size of the range.
Chris@16 1418 //!
Chris@16 1419 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 1420 //!
Chris@16 1421 //! <b>Note</b>: Does not affect the validity of iterators and references.
Chris@16 1422 //! No copy-constructors are called.
Chris@16 1423 template<class Iterator>
Chris@16 1424 void insert(Iterator b, Iterator e)
Chris@16 1425 { table_type::insert_equal(b, e); }
Chris@16 1426
Chris@16 1427 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 1428
Chris@16 1429 //! <b>Effects</b>: Erases the element pointed to by i.
Chris@16 1430 //!
Chris@16 1431 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1432 //!
Chris@16 1433 //! <b>Throws</b>: Nothing.
Chris@16 1434 //!
Chris@16 1435 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1436 //! to the erased element. No destructors are called.
Chris@16 1437 void erase(const_iterator i)
Chris@16 1438 { table_type::erase(i); }
Chris@16 1439
Chris@16 1440 //! <b>Effects</b>: Erases the range pointed to by b end e.
Chris@16 1441 //!
Chris@16 1442 //! <b>Complexity</b>: Average case O(std::distance(b, e)),
Chris@16 1443 //! worst case O(this->size()).
Chris@16 1444 //!
Chris@16 1445 //! <b>Throws</b>: Nothing.
Chris@16 1446 //!
Chris@16 1447 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1448 //! to the erased elements. No destructors are called.
Chris@16 1449 void erase(const_iterator b, const_iterator e)
Chris@16 1450 { table_type::erase(b, e); }
Chris@16 1451
Chris@16 1452 //! <b>Effects</b>: Erases all the elements with the given value.
Chris@16 1453 //!
Chris@16 1454 //! <b>Returns</b>: The number of erased elements.
Chris@16 1455 //!
Chris@16 1456 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 1457 //! Worst case O(this->size()).
Chris@16 1458 //!
Chris@16 1459 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 1460 //!
Chris@16 1461 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1462 //! to the erased elements. No destructors are called.
Chris@16 1463 size_type erase(const_reference value)
Chris@16 1464 { return table_type::erase(value); }
Chris@16 1465
Chris@16 1466 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1467 //! the same hash values as the stored hasher. The difference is that
Chris@16 1468 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1469 //!
Chris@16 1470 //! "key_value_equal" must be a equality function that induces
Chris@16 1471 //! the same equality as key_equal. The difference is that
Chris@16 1472 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1473 //!
Chris@16 1474 //! <b>Effects</b>: Erases all the elements that have the same hash and
Chris@16 1475 //! compare equal with the given key.
Chris@16 1476 //!
Chris@16 1477 //! <b>Returns</b>: The number of erased elements.
Chris@16 1478 //!
Chris@16 1479 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 1480 //! Worst case O(this->size()).
Chris@16 1481 //!
Chris@16 1482 //! <b>Throws</b>: If the hash_func or the equal_func functors throws.
Chris@16 1483 //! Basic guarantee.
Chris@16 1484 //!
Chris@16 1485 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1486 //! to the erased elements. No destructors are called.
Chris@16 1487 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1488 size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 1489 { return table_type::erase(key, hash_func, equal_func); }
Chris@16 1490
Chris@16 1491 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1492 //!
Chris@16 1493 //! <b>Effects</b>: Erases the element pointed to by i.
Chris@16 1494 //! Disposer::operator()(pointer) is called for the removed element.
Chris@16 1495 //!
Chris@16 1496 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1497 //!
Chris@16 1498 //! <b>Throws</b>: Nothing.
Chris@16 1499 //!
Chris@16 1500 //! <b>Note</b>: Invalidates the iterators
Chris@16 1501 //! to the erased elements.
Chris@16 1502 template<class Disposer>
Chris@16 1503 void erase_and_dispose(const_iterator i, Disposer disposer
Chris@16 1504 /// @cond
Chris@16 1505 , typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
Chris@16 1506 /// @endcond
Chris@16 1507 )
Chris@16 1508 { table_type::erase_and_dispose(i, disposer); }
Chris@16 1509
Chris@16 1510 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
Chris@16 1511 template<class Disposer>
Chris@16 1512 void erase_and_dispose(const_iterator i, Disposer disposer)
Chris@16 1513 { this->erase_and_dispose(const_iterator(i), disposer); }
Chris@16 1514 #endif
Chris@16 1515
Chris@16 1516 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1517 //!
Chris@16 1518 //! <b>Effects</b>: Erases the range pointed to by b end e.
Chris@16 1519 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 1520 //!
Chris@16 1521 //! <b>Complexity</b>: Average case O(std::distance(b, e)),
Chris@16 1522 //! worst case O(this->size()).
Chris@16 1523 //!
Chris@16 1524 //! <b>Throws</b>: Nothing.
Chris@16 1525 //!
Chris@16 1526 //! <b>Note</b>: Invalidates the iterators
Chris@16 1527 //! to the erased elements.
Chris@16 1528 template<class Disposer>
Chris@16 1529 void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
Chris@16 1530 { table_type::erase_and_dispose(b, e, disposer); }
Chris@16 1531
Chris@16 1532 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1533 //!
Chris@16 1534 //! <b>Effects</b>: Erases all the elements with the given value.
Chris@16 1535 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 1536 //!
Chris@16 1537 //! <b>Returns</b>: The number of erased elements.
Chris@16 1538 //!
Chris@16 1539 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 1540 //! Worst case O(this->size()).
Chris@16 1541 //!
Chris@16 1542 //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
Chris@16 1543 //!
Chris@16 1544 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1545 //! to the erased elements. No destructors are called.
Chris@16 1546 template<class Disposer>
Chris@16 1547 size_type erase_and_dispose(const_reference value, Disposer disposer)
Chris@16 1548 { return table_type::erase_and_dispose(value, disposer); }
Chris@16 1549
Chris@16 1550 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1551 //!
Chris@16 1552 //! <b>Effects</b>: Erases all the elements with the given key.
Chris@16 1553 //! according to the comparison functor "equal_func".
Chris@16 1554 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 1555 //!
Chris@16 1556 //! <b>Returns</b>: The number of erased elements.
Chris@16 1557 //!
Chris@16 1558 //! <b>Complexity</b>: Average case O(this->count(value)).
Chris@16 1559 //! Worst case O(this->size()).
Chris@16 1560 //!
Chris@16 1561 //! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee.
Chris@16 1562 //!
Chris@16 1563 //! <b>Note</b>: Invalidates the iterators
Chris@16 1564 //! to the erased elements.
Chris@16 1565 template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer>
Chris@16 1566 size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func, Disposer disposer)
Chris@16 1567 { return table_type::erase_and_dispose(key, hash_func, equal_func, disposer); }
Chris@16 1568
Chris@16 1569 //! <b>Effects</b>: Erases all the elements of the container.
Chris@16 1570 //!
Chris@16 1571 //! <b>Complexity</b>: Linear to the number of elements on the container.
Chris@16 1572 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
Chris@16 1573 //!
Chris@16 1574 //! <b>Throws</b>: Nothing.
Chris@16 1575 //!
Chris@16 1576 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1577 //! to the erased elements. No destructors are called.
Chris@16 1578 void clear()
Chris@16 1579 { return table_type::clear(); }
Chris@16 1580
Chris@16 1581 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
Chris@16 1582 //!
Chris@16 1583 //! <b>Effects</b>: Erases all the elements of the container.
Chris@16 1584 //!
Chris@16 1585 //! <b>Complexity</b>: Linear to the number of elements on the container.
Chris@16 1586 //! Disposer::operator()(pointer) is called for the removed elements.
Chris@16 1587 //!
Chris@16 1588 //! <b>Throws</b>: Nothing.
Chris@16 1589 //!
Chris@16 1590 //! <b>Note</b>: Invalidates the iterators (but not the references)
Chris@16 1591 //! to the erased elements. No destructors are called.
Chris@16 1592 template<class Disposer>
Chris@16 1593 void clear_and_dispose(Disposer disposer)
Chris@16 1594 { return table_type::clear_and_dispose(disposer); }
Chris@16 1595
Chris@16 1596 //! <b>Effects</b>: Returns the number of contained elements with the given key
Chris@16 1597 //!
Chris@16 1598 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1599 //!
Chris@16 1600 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1601 size_type count(const_reference value) const
Chris@16 1602 { return table_type::count(value); }
Chris@16 1603
Chris@16 1604 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1605 //! the same hash values as the stored hasher. The difference is that
Chris@16 1606 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1607 //!
Chris@16 1608 //! "key_value_equal" must be a equality function that induces
Chris@16 1609 //! the same equality as key_equal. The difference is that
Chris@16 1610 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1611 //!
Chris@16 1612 //! <b>Effects</b>: Returns the number of contained elements with the given key
Chris@16 1613 //!
Chris@16 1614 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1615 //!
Chris@16 1616 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1617 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1618 size_type count(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 1619 { return table_type::count(key, hash_func, equal_func); }
Chris@16 1620
Chris@16 1621 //! <b>Effects</b>: Finds an iterator to the first element whose value is
Chris@16 1622 //! "value" or end() if that element does not exist.
Chris@16 1623 //!
Chris@16 1624 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1625 //!
Chris@16 1626 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1627 iterator find(const_reference value)
Chris@16 1628 { return table_type::find(value); }
Chris@16 1629
Chris@16 1630 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1631 //! the same hash values as the stored hasher. The difference is that
Chris@16 1632 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1633 //!
Chris@16 1634 //! "key_value_equal" must be a equality function that induces
Chris@16 1635 //! the same equality as key_equal. The difference is that
Chris@16 1636 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1637 //!
Chris@16 1638 //! <b>Effects</b>: Finds an iterator to the first element whose key is
Chris@16 1639 //! "key" according to the given hasher and equality functor or end() if
Chris@16 1640 //! that element does not exist.
Chris@16 1641 //!
Chris@16 1642 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1643 //!
Chris@16 1644 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1645 //!
Chris@16 1646 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 1647 //! is expensive and the value_type can be compared with a cheaper
Chris@16 1648 //! key type. Usually this key is part of the value_type.
Chris@16 1649 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1650 iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 1651 { return table_type::find(key, hash_func, equal_func); }
Chris@16 1652
Chris@16 1653 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
Chris@16 1654 //! "key" or end() if that element does not exist.
Chris@16 1655 //!
Chris@16 1656 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1657 //!
Chris@16 1658 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1659 const_iterator find(const_reference value) const
Chris@16 1660 { return table_type::find(value); }
Chris@16 1661
Chris@16 1662 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1663 //! the same hash values as the stored hasher. The difference is that
Chris@16 1664 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1665 //!
Chris@16 1666 //! "key_value_equal" must be a equality function that induces
Chris@16 1667 //! the same equality as key_equal. The difference is that
Chris@16 1668 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1669 //!
Chris@16 1670 //! <b>Effects</b>: Finds an iterator to the first element whose key is
Chris@16 1671 //! "key" according to the given hasher and equality functor or end() if
Chris@16 1672 //! that element does not exist.
Chris@16 1673 //!
Chris@16 1674 //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
Chris@16 1675 //!
Chris@16 1676 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1677 //!
Chris@16 1678 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 1679 //! is expensive and the value_type can be compared with a cheaper
Chris@16 1680 //! key type. Usually this key is part of the value_type.
Chris@16 1681 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1682 const_iterator find(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 1683 { return table_type::find(key, hash_func, equal_func); }
Chris@16 1684
Chris@16 1685 //! <b>Effects</b>: Returns a range containing all elements with values equivalent
Chris@16 1686 //! to value. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 1687 //! elements exist.
Chris@16 1688 //!
Chris@16 1689 //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
Chris@16 1690 //!
Chris@16 1691 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1692 std::pair<iterator,iterator> equal_range(const_reference value)
Chris@16 1693 { return table_type::equal_range(value); }
Chris@16 1694
Chris@16 1695 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1696 //! the same hash values as the stored hasher. The difference is that
Chris@16 1697 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1698 //!
Chris@16 1699 //! "key_value_equal" must be a equality function that induces
Chris@16 1700 //! the same equality as key_equal. The difference is that
Chris@16 1701 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1702 //!
Chris@16 1703 //! <b>Effects</b>: Returns a range containing all elements with equivalent
Chris@16 1704 //! keys. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 1705 //! elements exist.
Chris@16 1706 //!
Chris@16 1707 //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)).
Chris@16 1708 //! Worst case O(this->size()).
Chris@16 1709 //!
Chris@16 1710 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1711 //!
Chris@16 1712 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 1713 //! is expensive and the value_type can be compared with a cheaper
Chris@16 1714 //! key type. Usually this key is part of the value_type.
Chris@16 1715 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1716 std::pair<iterator,iterator> equal_range
Chris@16 1717 (const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
Chris@16 1718 { return table_type::equal_range(key, hash_func, equal_func); }
Chris@16 1719
Chris@16 1720 //! <b>Effects</b>: Returns a range containing all elements with values equivalent
Chris@16 1721 //! to value. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 1722 //! elements exist.
Chris@16 1723 //!
Chris@16 1724 //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
Chris@16 1725 //!
Chris@16 1726 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1727 std::pair<const_iterator, const_iterator>
Chris@16 1728 equal_range(const_reference value) const
Chris@16 1729 { return table_type::equal_range(value); }
Chris@16 1730
Chris@16 1731 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1732 //! the same hash values as the stored hasher. The difference is that
Chris@16 1733 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1734 //!
Chris@16 1735 //! "key_value_equal" must be a equality function that induces
Chris@16 1736 //! the same equality as key_equal. The difference is that
Chris@16 1737 //! "key_value_equal" compares an arbitrary key with the contained values.
Chris@16 1738 //!
Chris@16 1739 //! <b>Effects</b>: Returns a range containing all elements with equivalent
Chris@16 1740 //! keys. Returns std::make_pair(this->end(), this->end()) if no such
Chris@16 1741 //! elements exist.
Chris@16 1742 //!
Chris@16 1743 //! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)).
Chris@16 1744 //! Worst case O(this->size()).
Chris@16 1745 //!
Chris@16 1746 //! <b>Throws</b>: If the internal hasher or the equality functor throws.
Chris@16 1747 //!
Chris@16 1748 //! <b>Note</b>: This function is used when constructing a value_type
Chris@16 1749 //! is expensive and the value_type can be compared with a cheaper
Chris@16 1750 //! key type. Usually this key is part of the value_type.
Chris@16 1751 template<class KeyType, class KeyHasher, class KeyValueEqual>
Chris@16 1752 std::pair<const_iterator, const_iterator>
Chris@16 1753 equal_range(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) const
Chris@16 1754 { return table_type::equal_range(key, hash_func, equal_func); }
Chris@16 1755
Chris@16 1756 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_multiset of
Chris@16 1757 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1758 //!
Chris@16 1759 //! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_multiset
Chris@16 1760 //! that points to the value
Chris@16 1761 //!
Chris@16 1762 //! <b>Complexity</b>: Constant.
Chris@16 1763 //!
Chris@16 1764 //! <b>Throws</b>: If the hash function throws.
Chris@16 1765 iterator iterator_to(reference value)
Chris@16 1766 { return table_type::iterator_to(value); }
Chris@16 1767
Chris@16 1768 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_multiset of
Chris@16 1769 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1770 //!
Chris@16 1771 //! <b>Effects</b>: Returns: a valid const_iterator belonging to the
Chris@16 1772 //! unordered_multiset that points to the value
Chris@16 1773 //!
Chris@16 1774 //! <b>Complexity</b>: Constant.
Chris@16 1775 //!
Chris@16 1776 //! <b>Throws</b>: If the hash function throws.
Chris@16 1777 const_iterator iterator_to(const_reference value) const
Chris@16 1778 { return table_type::iterator_to(value); }
Chris@16 1779
Chris@16 1780 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 1781 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1782 //!
Chris@16 1783 //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
Chris@16 1784 //! that points to the value
Chris@16 1785 //!
Chris@16 1786 //! <b>Complexity</b>: Constant.
Chris@16 1787 //!
Chris@16 1788 //! <b>Throws</b>: Nothing.
Chris@16 1789 //!
Chris@16 1790 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
Chris@16 1791 //! is stateless.
Chris@16 1792 static local_iterator s_local_iterator_to(reference value)
Chris@16 1793 { return table_type::s_local_iterator_to(value); }
Chris@16 1794
Chris@16 1795 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 1796 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1797 //!
Chris@16 1798 //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
Chris@16 1799 //! the unordered_set that points to the value
Chris@16 1800 //!
Chris@16 1801 //! <b>Complexity</b>: Constant.
Chris@16 1802 //!
Chris@16 1803 //! <b>Throws</b>: Nothing.
Chris@16 1804 //!
Chris@16 1805 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
Chris@16 1806 //! is stateless.
Chris@16 1807 static const_local_iterator s_local_iterator_to(const_reference value)
Chris@16 1808 { return table_type::s_local_iterator_to(value); }
Chris@16 1809
Chris@16 1810 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 1811 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1812 //!
Chris@16 1813 //! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
Chris@16 1814 //! that points to the value
Chris@16 1815 //!
Chris@16 1816 //! <b>Complexity</b>: Constant.
Chris@16 1817 //!
Chris@16 1818 //! <b>Throws</b>: Nothing.
Chris@16 1819 local_iterator local_iterator_to(reference value)
Chris@16 1820 { return table_type::local_iterator_to(value); }
Chris@16 1821
Chris@16 1822 //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
Chris@16 1823 //! appropriate type. Otherwise the behavior is undefined.
Chris@16 1824 //!
Chris@16 1825 //! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
Chris@16 1826 //! the unordered_set that points to the value
Chris@16 1827 //!
Chris@16 1828 //! <b>Complexity</b>: Constant.
Chris@16 1829 //!
Chris@16 1830 //! <b>Throws</b>: Nothing.
Chris@16 1831 const_local_iterator local_iterator_to(const_reference value) const
Chris@16 1832 { return table_type::local_iterator_to(value); }
Chris@16 1833
Chris@16 1834 //! <b>Effects</b>: Returns the number of buckets passed in the constructor
Chris@16 1835 //! or the last rehash function.
Chris@16 1836 //!
Chris@16 1837 //! <b>Complexity</b>: Constant.
Chris@16 1838 //!
Chris@16 1839 //! <b>Throws</b>: Nothing.
Chris@16 1840 size_type bucket_count() const
Chris@16 1841 { return table_type::bucket_count(); }
Chris@16 1842
Chris@16 1843 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1844 //!
Chris@16 1845 //! <b>Effects</b>: Returns the number of elements in the nth bucket.
Chris@16 1846 //!
Chris@16 1847 //! <b>Complexity</b>: Constant.
Chris@16 1848 //!
Chris@16 1849 //! <b>Throws</b>: Nothing.
Chris@16 1850 size_type bucket_size(size_type n) const
Chris@16 1851 { return table_type::bucket_size(n); }
Chris@16 1852
Chris@16 1853 //! <b>Effects</b>: Returns the index of the bucket in which elements
Chris@16 1854 //! with keys equivalent to k would be found, if any such element existed.
Chris@16 1855 //!
Chris@16 1856 //! <b>Complexity</b>: Constant.
Chris@16 1857 //!
Chris@16 1858 //! <b>Throws</b>: If the hash functor throws.
Chris@16 1859 //!
Chris@16 1860 //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
Chris@16 1861 size_type bucket(const value_type& k) const
Chris@16 1862 { return table_type::bucket(k); }
Chris@16 1863
Chris@16 1864 //! <b>Requires</b>: "hash_func" must be a hash function that induces
Chris@16 1865 //! the same hash values as the stored hasher. The difference is that
Chris@16 1866 //! "hash_func" hashes the given key instead of the value_type.
Chris@16 1867 //!
Chris@16 1868 //! <b>Effects</b>: Returns the index of the bucket in which elements
Chris@16 1869 //! with keys equivalent to k would be found, if any such element existed.
Chris@16 1870 //!
Chris@16 1871 //! <b>Complexity</b>: Constant.
Chris@16 1872 //!
Chris@16 1873 //! <b>Throws</b>: If the hash functor throws.
Chris@16 1874 //!
Chris@16 1875 //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
Chris@16 1876 template<class KeyType, class KeyHasher>
Chris@16 1877 size_type bucket(const KeyType& k, const KeyHasher &hash_func) const
Chris@16 1878 { return table_type::bucket(k, hash_func); }
Chris@16 1879
Chris@16 1880 //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor
Chris@16 1881 //! or the last rehash function.
Chris@16 1882 //!
Chris@16 1883 //! <b>Complexity</b>: Constant.
Chris@16 1884 //!
Chris@16 1885 //! <b>Throws</b>: Nothing.
Chris@16 1886 bucket_ptr bucket_pointer() const
Chris@16 1887 { return table_type::bucket_pointer(); }
Chris@16 1888
Chris@16 1889 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1890 //!
Chris@16 1891 //! <b>Effects</b>: Returns a local_iterator pointing to the beginning
Chris@16 1892 //! of the sequence stored in the bucket n.
Chris@16 1893 //!
Chris@16 1894 //! <b>Complexity</b>: Constant.
Chris@16 1895 //!
Chris@16 1896 //! <b>Throws</b>: Nothing.
Chris@16 1897 //!
Chris@16 1898 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1899 //! containing all of the elements in the nth bucket.
Chris@16 1900 local_iterator begin(size_type n)
Chris@16 1901 { return table_type::begin(n); }
Chris@16 1902
Chris@16 1903 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1904 //!
Chris@16 1905 //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
Chris@16 1906 //! of the sequence stored in the bucket n.
Chris@16 1907 //!
Chris@16 1908 //! <b>Complexity</b>: Constant.
Chris@16 1909 //!
Chris@16 1910 //! <b>Throws</b>: Nothing.
Chris@16 1911 //!
Chris@16 1912 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1913 //! containing all of the elements in the nth bucket.
Chris@16 1914 const_local_iterator begin(size_type n) const
Chris@16 1915 { return table_type::begin(n); }
Chris@16 1916
Chris@16 1917 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1918 //!
Chris@16 1919 //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
Chris@16 1920 //! of the sequence stored in the bucket n.
Chris@16 1921 //!
Chris@16 1922 //! <b>Complexity</b>: Constant.
Chris@16 1923 //!
Chris@16 1924 //! <b>Throws</b>: Nothing.
Chris@16 1925 //!
Chris@16 1926 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1927 //! containing all of the elements in the nth bucket.
Chris@16 1928 const_local_iterator cbegin(size_type n) const
Chris@16 1929 { return table_type::cbegin(n); }
Chris@16 1930
Chris@16 1931 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1932 //!
Chris@16 1933 //! <b>Effects</b>: Returns a local_iterator pointing to the end
Chris@16 1934 //! of the sequence stored in the bucket n.
Chris@16 1935 //!
Chris@16 1936 //! <b>Complexity</b>: Constant.
Chris@16 1937 //!
Chris@16 1938 //! <b>Throws</b>: Nothing.
Chris@16 1939 //!
Chris@16 1940 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1941 //! containing all of the elements in the nth bucket.
Chris@16 1942 local_iterator end(size_type n)
Chris@16 1943 { return table_type::end(n); }
Chris@16 1944
Chris@16 1945 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1946 //!
Chris@16 1947 //! <b>Effects</b>: Returns a const_local_iterator pointing to the end
Chris@16 1948 //! of the sequence stored in the bucket n.
Chris@16 1949 //!
Chris@16 1950 //! <b>Complexity</b>: Constant.
Chris@16 1951 //!
Chris@16 1952 //! <b>Throws</b>: Nothing.
Chris@16 1953 //!
Chris@16 1954 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1955 //! containing all of the elements in the nth bucket.
Chris@16 1956 const_local_iterator end(size_type n) const
Chris@16 1957 { return table_type::end(n); }
Chris@16 1958
Chris@16 1959 //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
Chris@16 1960 //!
Chris@16 1961 //! <b>Effects</b>: Returns a const_local_iterator pointing to the end
Chris@16 1962 //! of the sequence stored in the bucket n.
Chris@16 1963 //!
Chris@16 1964 //! <b>Complexity</b>: Constant.
Chris@16 1965 //!
Chris@16 1966 //! <b>Throws</b>: Nothing.
Chris@16 1967 //!
Chris@16 1968 //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
Chris@16 1969 //! containing all of the elements in the nth bucket.
Chris@16 1970 const_local_iterator cend(size_type n) const
Chris@16 1971 { return table_type::cend(n); }
Chris@16 1972
Chris@16 1973 //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array
Chris@16 1974 //! or the same as the old bucket array. new_size is the length of the
Chris@16 1975 //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer()
Chris@16 1976 //! n can be bigger or smaller than this->bucket_count().
Chris@16 1977 //!
Chris@16 1978 //! <b>Effects</b>: Updates the internal reference with the new bucket erases
Chris@16 1979 //! the values from the old bucket and inserts then in the new one.
Chris@16 1980 //!
Chris@16 1981 //! If store_hash option is true, this method does not use the hash function.
Chris@16 1982 //!
Chris@16 1983 //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic.
Chris@16 1984 //!
Chris@16 1985 //! <b>Throws</b>: If the hasher functor throws.
Chris@16 1986 void rehash(const bucket_traits &new_bucket_traits)
Chris@16 1987 { table_type::rehash(new_bucket_traits); }
Chris@16 1988
Chris@16 1989 //! <b>Requires</b>:
Chris@16 1990 //!
Chris@16 1991 //! <b>Effects</b>:
Chris@16 1992 //!
Chris@16 1993 //! <b>Complexity</b>:
Chris@16 1994 //!
Chris@16 1995 //! <b>Throws</b>:
Chris@16 1996 //!
Chris@16 1997 //! <b>Note</b>: this method is only available if incremental<true> option is activated.
Chris@16 1998 bool incremental_rehash(bool grow = true)
Chris@16 1999 { return table_type::incremental_rehash(grow); }
Chris@16 2000
Chris@16 2001 //! <b>Note</b>: this method is only available if incremental<true> option is activated.
Chris@16 2002 bool incremental_rehash(const bucket_traits &new_bucket_traits)
Chris@16 2003 { return table_type::incremental_rehash(new_bucket_traits); }
Chris@16 2004
Chris@16 2005 //! <b>Requires</b>:
Chris@16 2006 //!
Chris@16 2007 //! <b>Effects</b>:
Chris@16 2008 //!
Chris@16 2009 //! <b>Complexity</b>:
Chris@16 2010 //!
Chris@16 2011 //! <b>Throws</b>:
Chris@16 2012 size_type split_count() const
Chris@16 2013 { return table_type::split_count(); }
Chris@16 2014
Chris@16 2015 //! <b>Effects</b>: Returns the nearest new bucket count optimized for
Chris@16 2016 //! the container that is bigger than n. This suggestion can be used
Chris@16 2017 //! to create bucket arrays with a size that will usually improve
Chris@16 2018 //! container's performance. If such value does not exist, the
Chris@16 2019 //! higher possible value is returned.
Chris@16 2020 //!
Chris@16 2021 //! <b>Complexity</b>: Amortized constant time.
Chris@16 2022 //!
Chris@16 2023 //! <b>Throws</b>: Nothing.
Chris@16 2024 static size_type suggested_upper_bucket_count(size_type n)
Chris@16 2025 { return table_type::suggested_upper_bucket_count(n); }
Chris@16 2026
Chris@16 2027 //! <b>Effects</b>: Returns the nearest new bucket count optimized for
Chris@16 2028 //! the container that is smaller than n. This suggestion can be used
Chris@16 2029 //! to create bucket arrays with a size that will usually improve
Chris@16 2030 //! container's performance. If such value does not exist, the
Chris@16 2031 //! lower possible value is returned.
Chris@16 2032 //!
Chris@16 2033 //! <b>Complexity</b>: Amortized constant time.
Chris@16 2034 //!
Chris@16 2035 //! <b>Throws</b>: Nothing.
Chris@16 2036 static size_type suggested_lower_bucket_count(size_type n)
Chris@16 2037 { return table_type::suggested_lower_bucket_count(n); }
Chris@16 2038
Chris@16 2039 #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 2040 };
Chris@16 2041
Chris@16 2042 //! Helper metafunction to define an \c unordered_multiset that yields to the same type when the
Chris@16 2043 //! same options (either explicitly or implicitly) are used.
Chris@16 2044 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 2045 template<class T, class ...Options>
Chris@16 2046 #else
Chris@16 2047 template<class T, class O1 = void, class O2 = void
Chris@16 2048 , class O3 = void, class O4 = void
Chris@16 2049 , class O5 = void, class O6 = void
Chris@16 2050 , class O7 = void, class O8 = void
Chris@16 2051 , class O9 = void, class O10= void
Chris@16 2052 >
Chris@16 2053 #endif
Chris@16 2054 struct make_unordered_multiset
Chris@16 2055 {
Chris@16 2056 /// @cond
Chris@16 2057 typedef typename pack_options
Chris@16 2058 < hashtable_defaults,
Chris@16 2059 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 2060 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 2061 #else
Chris@16 2062 Options...
Chris@16 2063 #endif
Chris@16 2064 >::type packed_options;
Chris@16 2065
Chris@16 2066 typedef typename detail::get_value_traits
Chris@16 2067 <T, typename packed_options::proto_value_traits>::type value_traits;
Chris@16 2068
Chris@16 2069 typedef typename make_real_bucket_traits
Chris@16 2070 <T, true, packed_options>::type real_bucket_traits;
Chris@16 2071
Chris@16 2072 typedef unordered_multiset_impl
Chris@16 2073 < value_traits
Chris@16 2074 , typename packed_options::hash
Chris@16 2075 , typename packed_options::equal
Chris@16 2076 , typename packed_options::size_type
Chris@16 2077 , real_bucket_traits
Chris@16 2078 , (std::size_t(false)*hash_bool_flags::unique_keys_pos)
Chris@16 2079 | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
Chris@16 2080 | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
Chris@16 2081 | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
Chris@16 2082 | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
Chris@16 2083 | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
Chris@16 2084 > implementation_defined;
Chris@16 2085
Chris@16 2086 /// @endcond
Chris@16 2087 typedef implementation_defined type;
Chris@16 2088 };
Chris@16 2089
Chris@16 2090 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
Chris@16 2091
Chris@16 2092 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 2093 template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
Chris@16 2094 #else
Chris@16 2095 template<class T, class ...Options>
Chris@16 2096 #endif
Chris@16 2097 class unordered_multiset
Chris@16 2098 : public make_unordered_multiset<T,
Chris@16 2099 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 2100 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 2101 #else
Chris@16 2102 Options...
Chris@16 2103 #endif
Chris@16 2104 >::type
Chris@16 2105 {
Chris@16 2106 typedef typename make_unordered_multiset
Chris@16 2107 <T,
Chris@16 2108 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 2109 O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
Chris@16 2110 #else
Chris@16 2111 Options...
Chris@16 2112 #endif
Chris@16 2113 >::type Base;
Chris@16 2114 //Assert if passed value traits are compatible with the type
Chris@16 2115 BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
Chris@16 2116 BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset)
Chris@16 2117
Chris@16 2118 public:
Chris@16 2119 typedef typename Base::value_traits value_traits;
Chris@16 2120 typedef typename Base::bucket_traits bucket_traits;
Chris@16 2121 typedef typename Base::iterator iterator;
Chris@16 2122 typedef typename Base::const_iterator const_iterator;
Chris@16 2123 typedef typename Base::bucket_ptr bucket_ptr;
Chris@16 2124 typedef typename Base::size_type size_type;
Chris@16 2125 typedef typename Base::hasher hasher;
Chris@16 2126 typedef typename Base::key_equal key_equal;
Chris@16 2127
Chris@16 2128 explicit unordered_multiset( const bucket_traits &b_traits
Chris@16 2129 , const hasher & hash_func = hasher()
Chris@16 2130 , const key_equal &equal_func = key_equal()
Chris@16 2131 , const value_traits &v_traits = value_traits())
Chris@16 2132 : Base(b_traits, hash_func, equal_func, v_traits)
Chris@16 2133 {}
Chris@16 2134
Chris@16 2135 template<class Iterator>
Chris@16 2136 unordered_multiset( Iterator b
Chris@16 2137 , Iterator e
Chris@16 2138 , const bucket_traits &b_traits
Chris@16 2139 , const hasher & hash_func = hasher()
Chris@16 2140 , const key_equal &equal_func = key_equal()
Chris@16 2141 , const value_traits &v_traits = value_traits())
Chris@16 2142 : Base(b, e, b_traits, hash_func, equal_func, v_traits)
Chris@16 2143 {}
Chris@16 2144
Chris@16 2145 unordered_multiset(BOOST_RV_REF(unordered_multiset) x)
Chris@16 2146 : Base(::boost::move(static_cast<Base&>(x)))
Chris@16 2147 {}
Chris@16 2148
Chris@16 2149 unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
Chris@16 2150 { return static_cast<unordered_multiset&>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
Chris@16 2151 };
Chris@16 2152
Chris@16 2153 #endif
Chris@16 2154
Chris@16 2155 } //namespace intrusive
Chris@16 2156 } //namespace boost
Chris@16 2157
Chris@16 2158 #include <boost/intrusive/detail/config_end.hpp>
Chris@16 2159
Chris@16 2160 #endif //BOOST_INTRUSIVE_UNORDERED_SET_HPP