--- /dev/null
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// (C) Copyright Olaf Krzikalla 2004-2006.\r
+// (C) Copyright Ion GaztaƱaga 2006-2007\r
+//\r
+// Distributed under the Boost Software License, Version 1.0.\r
+// (See accompanying file LICENSE_1_0.txt or copy at\r
+// http://www.boost.org/LICENSE_1_0.txt)\r
+//\r
+// See http://www.boost.org/libs/intrusive for documentation.\r
+//\r
+/////////////////////////////////////////////////////////////////////////////\r
+#ifndef BOOST_INTRUSIVE_IHASHSET_HPP\r
+#define BOOST_INTRUSIVE_IHASHSET_HPP\r
+\r
+#include "detail/config_begin.hpp"\r
+#include "detail/ihashtable.hpp"\r
+#include <iterator>\r
+\r
+namespace boost {\r
+namespace intrusive {\r
+\r
+//! The class template iunordered_set is an intrusive container, that mimics most of \r
+//! the interface of std::tr1::unordered_set as described in the C++ TR1.\r
+//!\r
+//! iunordered_set is a pseudo-intrusive container: each object to be stored in the\r
+//! container must contain a proper hook, but the container also needs\r
+//! additional auxiliary memory to work: iunordered_set needs a pointer to an array\r
+//! of type `bucket_type` to be passed in the constructor. This bucket array must\r
+//! have at least the same lifetime as the container. This makes the use of\r
+//! iunordered_set more complicated than purely intrusive containers.\r
+//! `bucket_type` is default-constructible, copyable and assignable\r
+//!\r
+//! The template parameter ValueTraits is called "value traits". It stores\r
+//! information and operations about the type to be stored in the container.\r
+//!\r
+//! The template parameter Hash is a unary function object that take an argument\r
+//! of type ValueTraits::value_type and returns a value of type std::size_t.\r
+//!\r
+//! The template parameter Equal is a binary predicate that takes two arguments of\r
+//! type ValueTraits::value_type. Equal is an equivalence relation.\r
+//!\r
+//! If the user specifies ConstantTimeSize as "true", a member of type SizeType\r
+//! will be embedded in the class, that will keep track of the number of stored objects.\r
+//! This will allow constant-time O(1) size() member, instead of default O(N) size.\r
+//!\r
+//! iunordered_set only provides forward iterators but it provides 4 iterator types:\r
+//! iterator and const_iterator to navigate through the whole container and\r
+//! local_iterator and const_local_iterator to navigate through the values\r
+//! stored in a single bucket. Local iterators are faster and smaller.\r
+//!\r
+//! It's not recommended to use non ConstantTimeSize iunordered_sets because several\r
+//! key functions, like "empty()", become non-constant time functions. Non\r
+//! ConstantTimeSize iunordered_sets are mainly provided to support auto-unlink hooks.\r
+//!\r
+//! iunordered_set, unlike std::unordered_set, does not make automatic rehashings nor\r
+//! offers functions related to a load factor. Rehashing can be explicitly requested\r
+//! and the user must provide a new bucket array that will be used from that moment.\r
+//!\r
+//! Since no automatic rehashing is done, iterators are never invalidated when\r
+//! inserting or erasing elements. Iterators are only invalidated when rehasing.\r
+template< class ValueTraits\r
+ , class Hash = boost::hash<typename ValueTraits::value_type>\r
+ , class Equal = std::equal_to<typename ValueTraits::value_type>\r
+ , bool ConstantTimeSize = true\r
+ , class SizeType = std::size_t\r
+ >\r
+class iunordered_set\r
+{\r
+ private:\r
+ typedef detail::ihashtable<ValueTraits, Hash, Equal, ConstantTimeSize, SizeType> table_type;\r
+\r
+ //! This class is\r
+ //! non-copyable\r
+ iunordered_set (const iunordered_set&);\r
+\r
+ //! This class is\r
+ //! non-assignable\r
+ iunordered_set &operator =(const iunordered_set&);\r
+\r
+ typedef table_type implementation_defined;\r
+\r
+ public:\r
+ typedef typename ValueTraits::value_type value_type;\r
+ typedef typename ValueTraits::pointer pointer;\r
+ typedef typename ValueTraits::const_pointer const_pointer;\r
+ typedef value_type& reference;\r
+ typedef const value_type& const_reference;\r
+ typedef SizeType size_type;\r
+ typedef typename std::iterator_traits<pointer>::difference_type difference_type;\r
+ typedef value_type key_type;\r
+ typedef Equal key_equal;\r
+ typedef Hash hasher;\r
+ typedef typename implementation_defined::bucket_type bucket_type;\r
+ typedef typename boost::pointer_to_other<pointer, bucket_type>::type bucket_ptr;\r
+ typedef typename implementation_defined::iterator iterator;\r
+ typedef typename implementation_defined::const_iterator const_iterator;\r
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;\r
+ typedef typename implementation_defined::local_iterator local_iterator;\r
+ typedef typename implementation_defined::const_local_iterator const_local_iterator;\r
+\r
+ private:\r
+ table_type table_;\r
+\r
+ public:\r
+\r
+ //! <b>Requires</b>: buckets must not be being used by any other resource.\r
+ //!\r
+ //! <b>Effects</b>: Constructs an empty iunordered_set, storing a reference\r
+ //! to the bucket array and copies of the hasher and equal functors.\r
+ //! \r
+ //! <b>Complexity</b>: Constant. \r
+ //! \r
+ //! <b>Throws</b>: If value_traits::node_traits::node\r
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)\r
+ //! or the copy constructor or invocation of Hash or Equal throws. \r
+ //!\r
+ //! <b>Notes</b>: buckets array must be destroyed only after\r
+ //! *this is destroyed. \r
+ iunordered_set( bucket_ptr buckets\r
+ , size_type buckets_len\r
+ , const Hash & hasher = Hash()\r
+ , const Equal &equal = Equal()) \r
+ : table_(buckets, buckets_len, hasher, equal)\r
+ {}\r
+\r
+ //! <b>Requires</b>: buckets must not be being used by any other resource\r
+ //! and Dereferencing iterator must yield an lvalue of type value_type.\r
+ //! \r
+ //! <b>Effects</b>: Constructs an empty iunordered_set and inserts elements from \r
+ //! [b, e).\r
+ //! \r
+ //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N)\r
+ //! (with a good hash function and with buckets_len >= N),worst case O(N2).\r
+ //! \r
+ //! <b>Throws</b>: If value_traits::node_traits::node\r
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)\r
+ //! or the copy constructor or invocation of Hash or Equal throws. \r
+ //!\r
+ //! <b>Notes</b>: buckets array must be destroyed only after\r
+ //! *this is destroyed. \r
+ template<class Iterator>\r
+ iunordered_set( bucket_ptr buckets\r
+ , size_type buckets_len\r
+ , Iterator b\r
+ , Iterator e\r
+ , const Hash & hasher = Hash()\r
+ , const Equal &equal = Equal()) \r
+ : table_(buckets, buckets_len, hasher, equal)\r
+ { table_.insert_unique(b, e); }\r
+\r
+ //! <b>Effects</b>: Detaches all elements from this. The objects in the iunordered_set \r
+ //! are not deleted (i.e. no destructors are called).\r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements in the iunordered_set, if \r
+ //! it's a safe-mode or auto-unlink value. Otherwise constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ ~iunordered_set() \r
+ {}\r
+\r
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! Worst case (empty iunordered_set): O(this->bucket_count())\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ iterator begin()\r
+ { return table_.begin(); }\r
+\r
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning\r
+ //! of the iunordered_set.\r
+ //!\r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! Worst case (empty iunordered_set): O(this->bucket_count())\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ const_iterator begin() const\r
+ { return table_.begin(); }\r
+\r
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ iterator end()\r
+ { return table_.end(); }\r
+\r
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ const_iterator end() const\r
+ { return table_.end(); }\r
+\r
+ //! <b>Effects</b>: Returns the hasher object used by the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If hasher copy-constructor throws.\r
+ hasher hash_function() const\r
+ { return table_.hash_function(); }\r
+\r
+ //! <b>Effects</b>: Returns the key_equal object used by the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If key_equal copy-constructor throws.\r
+ key_equal key_eq() const\r
+ { return table_.key_eq(); }\r
+\r
+ //! <b>Effects</b>: Returns true is the container is empty.\r
+ //! \r
+ //! <b>Complexity</b>: if ConstantTimeSize is false, average constant time\r
+ //! (worst case, with empty() == true): O(this->bucket_count()).\r
+ //! Otherwise constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ bool empty() const\r
+ { return table_.empty(); }\r
+\r
+ //! <b>Effects</b>: Returns the number of elements stored in the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Linear to elements contained in *this if\r
+ //! ConstantTimeSize is false. Constant-time otherwise.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type size() const\r
+ { return table_.size(); }\r
+\r
+ //! <b>Requires</b>: the hasher and the equality function unqualified swap\r
+ //! call should not throw.\r
+ //! \r
+ //! <b>Effects</b>: Swaps the contents of two iunordered_sets.\r
+ //! Swaps also the contained bucket array and equality and hasher functors.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //!\r
+ //! <b>Throws</b>: If the swap() call for the comparison or hash functors\r
+ //! found using ADL throw. Basic guarantee.\r
+ void swap(iunordered_set& other)\r
+ { table_.swap(other.table_); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements from *this\r
+ //! calling Destroyer::operator()(pointer), clones all the \r
+ //! elements from src calling Cloner::operator()(const value_type &)\r
+ //! and inserts them on *this.\r
+ //!\r
+ //! If cloner throws, all cloned elements are unlinked and destroyed\r
+ //! calling Destroyer::operator()(pointer).\r
+ //! \r
+ //! <b>Complexity</b>: Linear to erased plus inserted elements.\r
+ //! \r
+ //! <b>Throws</b>: If cloner throws. Basic guarantee.\r
+ template <class Cloner, class Destroyer>\r
+ void clone_from(const iunordered_set &src, Cloner cloner, Destroyer destroyer)\r
+ { table_.clone_from(src.table_, cloner, destroyer); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue\r
+ //! \r
+ //! <b>Effects</b>: Tries to inserts value into the iunordered_set.\r
+ //!\r
+ //! <b>Returns</b>: If the value\r
+ //! is not already present inserts it and returns a pair containing the\r
+ //! iterator to the new value and true. If the value is already present\r
+ //! returns a pair containing an iterator to the already present value\r
+ //! and false.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.\r
+ //! \r
+ //! <b>Note</b>: Does not affect the validity of iterators and references.\r
+ //! No copy-constructors are called.\r
+ std::pair<iterator, bool> insert(value_type &value)\r
+ { return table_.insert_unique(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //! \r
+ //! <b>Effects</b>: Checks if a value can be inserted in the iunordered_set, using\r
+ //! a user provided key instead of the value itself.\r
+ //!\r
+ //! <b>Returns</b>: If an equivalent value is already present\r
+ //! returns a pair containing an iterator to the already present value\r
+ //! and false. If the value can be inserted returns true in the returned\r
+ //! pair boolean and fills "commit_data" that is meant to be used with\r
+ //! the "insert_commit" function.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //!\r
+ //! <b>Throws</b>: If hasher or key_value_equal throw. Strong guarantee.\r
+ //! \r
+ //! <b>Notes</b>: This function is used to improve performance when constructing\r
+ //! a value_type is expensive: if an equivalent value is already present\r
+ //! the constructed object must be discarded. Many times, the part of the\r
+ //! node that is used to impose the hash or the equality is much cheaper to\r
+ //! construct than the value_type and this function offers the possibility to\r
+ //! use that the part to check if the insertion will be successful.\r
+ //!\r
+ //! If the check is successful, the user can construct the value_type and use\r
+ //! "insert_commit" to insert the object in constant-time.\r
+ //!\r
+ //! "commit_data" remains valid for a subsequent "insert_commit" only if no more\r
+ //! objects are inserted or erased from the iunordered_set.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ std::pair<iterator, bool> insert_check\r
+ (const KeyType &key, KeyHasher hasher, KeyValueEqual key_value_equal, insert_commit_data &commit_data)\r
+ { return table_.insert_unique_check(key, hasher, key_value_equal, commit_data); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data\r
+ //! must have been obtained from a previous call to "insert_check".\r
+ //! No objects should have been inserted or erased from the iunordered_set between\r
+ //! the "insert_check" that filled "commit_data" and the call to "insert_commit".\r
+ //! \r
+ //! <b>Effects</b>: Inserts the value in the iunordered_set using the information obtained\r
+ //! from the "commit_data" that a previous "insert_check" filled.\r
+ //!\r
+ //! <b>Returns</b>: An iterator to the newly inserted object.\r
+ //! \r
+ //! <b>Complexity</b>: Constant time.\r
+ //!\r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Notes</b>: This function has only sense if a "insert_check" has been\r
+ //! previously executed to fill "commit_data". No value should be inserted or\r
+ //! erased between the "insert_check" and "insert_commit" calls.\r
+ iterator insert_commit(value_type &value, const insert_commit_data &commit_data)\r
+ { return table_.insert_unique_commit(value, commit_data); }\r
+\r
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue \r
+ //! of type value_type.\r
+ //! \r
+ //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e).\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e).\r
+ //! Worst case O(N*this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Does not affect the validity of iterators and references.\r
+ //! No copy-constructors are called.\r
+ template<class Iterator>\r
+ void insert(Iterator b, Iterator e)\r
+ { table_.insert_unique(b, e); }\r
+\r
+ //! <b>Effects</b>: Erases the element pointed to by i. \r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased element. No destructors are called.\r
+ void erase(const_iterator i)\r
+ { table_.erase(i); }\r
+\r
+ //! <b>Effects</b>: Erases the range pointed to by b end e. \r
+ //! \r
+ //! <b>Complexity</b>: Average case O(std::distance(b, e)),\r
+ //! worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ void erase(const_iterator b, const_iterator e)\r
+ { table_.erase(b, e); }\r
+\r
+ //! <b>Effects</b>: Erases all the elements with the given value.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ size_type erase(const value_type &value)\r
+ { return table_.erase(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements that have the same hash and\r
+ //! compare equal with the given key.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or equal throw. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ size_type erase(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.erase(key, hasher, equal); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases the element pointed to by i. \r
+ //! Destroyer::operator()(pointer) is called for the removed element.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators \r
+ //! to the erased elements.\r
+ template<class Destroyer>\r
+ iterator erase_and_destroy(const_iterator i, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(i, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases the range pointed to by b end e.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(std::distance(b, e)),\r
+ //! worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators\r
+ //! to the erased elements.\r
+ template<class Destroyer>\r
+ iterator erase_and_destroy(const_iterator b, const_iterator e, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(b, e, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements with the given value.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class Destroyer>\r
+ size_type erase_and_destroy(const value_type &value, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(value, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements with the given key.\r
+ //! according to the comparison functor "equal".\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //!\r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or key_value_equal throw. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators\r
+ //! to the erased elements.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual, class Destroyer>\r
+ size_type erase_and_destroy(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(key, hasher, equal, destroyer); }\r
+\r
+ //! <b>Effects</b>: Erases all of the elements. \r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements on the container.\r
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ void clear()\r
+ { return table_.clear(); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //! \r
+ //! <b>Effects</b>: Erases all of the elements. \r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements on the container.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class Destroyer>\r
+ void clear_and_destroy(Destroyer destroyer)\r
+ { return table_.clear_and_destroy(destroyer); }\r
+\r
+ //! <b>Effects</b>: Returns the number of contained elements with the given value\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ size_type count(const value_type &value) const\r
+ { return table_.find(value) != end(); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns the number of contained elements with the given key\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or equal throw.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual, class Destroyer>\r
+ size_type count(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.find(key, hasher, equal) != end(); }\r
+\r
+ //! <b>Effects</b>: Finds an iterator to the first element is equal to\r
+ //! "value" or end() if that element does not exist.\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ iterator find(const value_type &value)\r
+ { return table_.find(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is \r
+ //! "key" according to the given hasher and equality functor or end() if\r
+ //! that element does not exist.\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or equal throw.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ iterator find(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.find(key, hasher, equal); }\r
+\r
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is \r
+ //! "key" or end() if that element does not exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ const_iterator find(const value_type &value) const\r
+ { return table_.find(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is \r
+ //! "key" according to the given hasher and equality functor or end() if\r
+ //! that element does not exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or equal throw.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ const_iterator find(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.find(key, equal); }\r
+\r
+ //! <b>Effects</b>: Returns a range containing all elements with values equivalent\r
+ //! to value. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ std::pair<iterator,iterator> equal_range(const value_type &value)\r
+ { return table_.equal_range(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns a range containing all elements with equivalent\r
+ //! keys. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(key, hasher, equal)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or the equal throw.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.equal_range(key, hasher, equal); }\r
+\r
+ //! <b>Effects</b>: Returns a range containing all elements with values equivalent\r
+ //! to value. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ std::pair<const_iterator, const_iterator>\r
+ equal_range(const value_type &value) const\r
+ { return table_.equal_range(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns a range containing all elements with equivalent\r
+ //! keys. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(key, hasher, equal)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the hasher or equal throw.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ std::pair<const_iterator, const_iterator>\r
+ equal_range(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.equal_range(key, equal); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_set of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the iunordered_set\r
+ //! that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the internal hash function throws.\r
+ iterator current(value_type &value)\r
+ { return table_.current(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_set of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the\r
+ //! iunordered_set that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the internal hash function throws.\r
+ const_iterator current(const value_type &value) const\r
+ { return table_.current(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_set of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid local_iterator i belonging to the iunordered_set\r
+ //! that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static local_iterator current_local(value_type &value)\r
+ { return table_type::current_local(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_set of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid const_local_iterator i belonging to\r
+ //! the iunordered_set that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static const_local_iterator current_local(const value_type &value)\r
+ { return table_type::current_local(value); }\r
+\r
+ //! <b>Effects</b>: Returns the number of buckets passed in the constructor\r
+ //! or the last rehash function.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type bucket_count() const\r
+ { return table_.bucket_count(); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns the number of elements in the nth bucket.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type bucket_size(size_type n)\r
+ { return table_.bucket_size(n); }\r
+\r
+ //! <b>Effects</b>: Returns the index of the bucket in which elements\r
+ //! with keys equivalent to k would be found, if any such element existed.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the hash functor throws.\r
+ //!\r
+ //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).\r
+ size_type bucket(const key_type& k)\r
+ { return table_.bucket(k); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! <b>Effects</b>: Returns the index of the bucket in which elements\r
+ //! with keys equivalent to k would be found, if any such element existed.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If hasher throws.\r
+ //!\r
+ //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).\r
+ template<class KeyType, class KeyHasher>\r
+ size_type bucket(const KeyType& k, KeyHasher hasher)\r
+ { return table_.bucket(k, hasher); }\r
+\r
+ //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor\r
+ //! or the last rehash function.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ bucket_ptr bucket_pointer() const\r
+ { return table_.bucket_pointer(); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a local_iterator pointing to the beginning\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ local_iterator begin(size_type n)\r
+ { return table_.begin(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ const_local_iterator begin(size_type n) const\r
+ { return table_.begin(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a local_iterator pointing to the end\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ local_iterator end(size_type n)\r
+ { return table_.end(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a const_local_iterator pointing to the end\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ const_local_iterator end(size_type n) const\r
+ { return table_.end(n); }\r
+\r
+ //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array\r
+ //! or the same as the old bucket array. new_size is the length of the\r
+ //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer()\r
+ //! n can be bigger or smaller than this->bucket_count().\r
+ //!\r
+ //! <b>Effects</b>: Updates the internal reference with the new bucket erases\r
+ //! the values from the old bucket and inserts then in the new one. \r
+ //! \r
+ //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic.\r
+ //! \r
+ //! <b>Throws</b>: If the hasher functor throws. Basic guarantee.\r
+ void rehash(bucket_ptr new_buckets, size_type new_size)\r
+ { table_.rehash(new_buckets, new_size); }\r
+\r
+ //! <b>Effects</b>: Returns the nearest new bucket count optimized for\r
+ //! the container that is bigger than n. This suggestion can be used\r
+ //! to create bucket arrays with a size that will usually improve\r
+ //! container's performance. If such value does not exist, the \r
+ //! higher possible value is returned.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static size_type suggested_upper_bucket_count(size_type n)\r
+ { return table_type::suggested_upper_bucket_count(n); }\r
+\r
+ //! <b>Effects</b>: Returns the nearest new bucket count optimized for\r
+ //! the container that is smaller than n. This suggestion can be used\r
+ //! to create bucket arrays with a size that will usually improve\r
+ //! container's performance. If such value does not exist, the \r
+ //! lower possible value is returned.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static size_type suggested_lower_bucket_count(size_type n)\r
+ { return table_type::suggested_lower_bucket_count(n); }\r
+};\r
+\r
+//! The class template iunordered_multiset is an intrusive container, that mimics most of \r
+//! the interface of std::tr1::unordered_multiset as described in the C++ TR1.\r
+//!\r
+//! iunordered_multiset is a pseudo-intrusive container: each object to be stored in the\r
+//! container must contain a proper hook, but the container also needs\r
+//! additional auxiliary memory to work: iunordered_multiset needs a pointer to an array\r
+//! of type `bucket_type` to be passed in the constructor. This bucket array must\r
+//! have at least the same lifetime as the container. This makes the use of\r
+//! iunordered_multiset more complicated than purely intrusive containers.\r
+//! `bucket_type` is default-constructible, copyable and assignable\r
+//!\r
+//! The template parameter ValueTraits is called "value traits". It stores\r
+//! information and operations about the type to be stored in the container.\r
+//!\r
+//! The template parameter Hash is a unary function object that take an argument\r
+//! of type ValueTraits::value_type and returns a value of type std::size_t.\r
+//!\r
+//! The template parameter Equal is a binary predicate that takes two arguments of\r
+//! type ValueTraits::value_type. Equal is an equivalence relation.\r
+//!\r
+//! If the user specifies ConstantTimeSize as "true", a member of type SizeType\r
+//! will be embedded in the class, that will keep track of the number of stored objects.\r
+//! This will allow constant-time O(1) size() member, instead of default O(N) size.\r
+//!\r
+//! iunordered_multiset only provides forward iterators but it provides 4 iterator types:\r
+//! iterator and const_iterator to navigate through the whole container and\r
+//! local_iterator and const_local_iterator to navigate through the values\r
+//! stored in a single bucket. Local iterators are faster and smaller.\r
+//!\r
+//! It's not recommended to use non ConstantTimeSize iunordered_multisets because several\r
+//! key functions, like "empty()", become non-constant time functions. Non\r
+//! ConstantTimeSize iunordered_multisets are mainly provided to support auto-unlink hooks.\r
+//!\r
+//! iunordered_multiset, unlike std::unordered_set, does not make automatic rehashings nor\r
+//! offers functions related to a load factor. Rehashing can be explicitly requested\r
+//! and the user must provide a new bucket array that will be used from that moment.\r
+//!\r
+//! Since no automatic rehashing is done, iterators are never invalidated when\r
+//! inserting or erasing elements. Iterators are only invalidated when rehasing.\r
+template< class ValueTraits\r
+ , class Hash = boost::hash<typename ValueTraits::value_type>\r
+ , class Equal = std::equal_to<typename ValueTraits::value_type>\r
+ , bool ConstantTimeSize = true\r
+ , class SizeType = std::size_t\r
+ >\r
+class iunordered_multiset\r
+{\r
+ private:\r
+ typedef detail::ihashtable<ValueTraits, Hash, Equal, ConstantTimeSize, SizeType> table_type;\r
+\r
+ //! This class is\r
+ //! non-copyable\r
+ iunordered_multiset (const iunordered_multiset&);\r
+\r
+ //! This class is\r
+ //! non-assignable\r
+ iunordered_multiset &operator =(const iunordered_multiset&);\r
+\r
+ typedef table_type implementation_defined;\r
+\r
+ public:\r
+ typedef typename ValueTraits::value_type value_type;\r
+ typedef typename ValueTraits::pointer pointer;\r
+ typedef typename ValueTraits::const_pointer const_pointer;\r
+ typedef value_type& reference;\r
+ typedef const value_type& const_reference;\r
+ typedef SizeType size_type;\r
+ typedef typename std::iterator_traits<pointer>::difference_type difference_type;\r
+ typedef value_type key_type;\r
+ typedef Equal key_equal;\r
+ typedef Hash hasher;\r
+ typedef typename implementation_defined::bucket_type bucket_type;\r
+ typedef typename boost::pointer_to_other<pointer, bucket_type>::type bucket_ptr;\r
+ typedef typename implementation_defined::iterator iterator;\r
+ typedef typename implementation_defined::const_iterator const_iterator;\r
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;\r
+ typedef typename implementation_defined::local_iterator local_iterator;\r
+ typedef typename implementation_defined::const_local_iterator const_local_iterator;\r
+\r
+ private:\r
+ table_type table_;\r
+\r
+ public:\r
+\r
+ //! <b>Requires</b>: buckets must not be being used by any other resource.\r
+ //!\r
+ //! <b>Effects</b>: Constructs an empty iunordered_multiset, storing a reference\r
+ //! to the bucket array and copies of the hasher and equal functors.\r
+ //! \r
+ //! <b>Complexity</b>: Constant. \r
+ //! \r
+ //! <b>Throws</b>: If value_traits::node_traits::node\r
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)\r
+ //! or the copy constructor or invocation of Hash or Equal throws. \r
+ //!\r
+ //! <b>Notes</b>: buckets array must be destroyed only after\r
+ //! *this is destroyed. \r
+ iunordered_multiset ( bucket_ptr buckets\r
+ , size_type buckets_len\r
+ , const Hash & hasher = Hash()\r
+ , const Equal &equal = Equal()) \r
+ : table_(buckets, buckets_len, hasher, equal)\r
+ {}\r
+\r
+ //! <b>Requires</b>: buckets must not be being used by any other resource\r
+ //! and Dereferencing iterator must yield an lvalue of type value_type.\r
+ //! \r
+ //! <b>Effects</b>: Constructs an empty iunordered_multiset and inserts elements from \r
+ //! [b, e).\r
+ //! \r
+ //! <b>Complexity</b>: If N is std::distance(b, e): Average case is O(N)\r
+ //! (with a good hash function and with buckets_len >= N),worst case O(N2).\r
+ //! \r
+ //! <b>Throws</b>: If value_traits::node_traits::node\r
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)\r
+ //! or the copy constructor or invocation of Hash or Equal throws. \r
+ //!\r
+ //! <b>Notes</b>: buckets array must be destroyed only after\r
+ //! *this is destroyed.\r
+ template<class Iterator>\r
+ iunordered_multiset ( bucket_ptr buckets\r
+ , size_type buckets_len\r
+ , Iterator b\r
+ , Iterator e\r
+ , const Hash & hasher = Hash()\r
+ , const Equal &equal = Equal()) \r
+ : table_(buckets, buckets_len, hasher, equal)\r
+ { table_.insert_equal(b, e); }\r
+\r
+ //! <b>Effects</b>: Detaches all elements from this. The objects in the iunordered_multiset \r
+ //! are not deleted (i.e. no destructors are called).\r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements in the iunordered_multiset, if \r
+ //! it's a safe-mode or auto-unlink value. Otherwise constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ ~iunordered_multiset() \r
+ {}\r
+\r
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the iunordered_multiset.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! Worst case (empty iunordered_multiset): O(this->bucket_count())\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ iterator begin()\r
+ { return table_.begin(); }\r
+\r
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning\r
+ //! of the iunordered_multiset.\r
+ //!\r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! Worst case (empty iunordered_multiset): O(this->bucket_count())\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ const_iterator begin() const\r
+ { return table_.begin(); }\r
+\r
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the iunordered_multiset.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ iterator end()\r
+ { return table_.end(); }\r
+\r
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the iunordered_multiset.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ const_iterator end() const\r
+ { return table_.end(); }\r
+\r
+ //! <b>Effects</b>: Returns the hasher object used by the iunordered_set.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If hasher copy-constructor throws.\r
+ hasher hash_function() const\r
+ { return table_.hash_function(); }\r
+\r
+ //! <b>Effects</b>: Returns the key_equal object used by the iunordered_multiset.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If key_equal copy-constructor throws.\r
+ key_equal key_eq() const\r
+ { return table_.key_eq(); }\r
+\r
+ //! <b>Effects</b>: Returns true is the container is empty.\r
+ //! \r
+ //! <b>Complexity</b>: if ConstantTimeSize is false, average constant time\r
+ //! (worst case, with empty() == true): O(this->bucket_count()).\r
+ //! Otherwise constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ bool empty() const\r
+ { return table_.empty(); }\r
+\r
+ //! <b>Effects</b>: Returns the number of elements stored in the iunordered_multiset.\r
+ //! \r
+ //! <b>Complexity</b>: Linear to elements contained in *this if\r
+ //! ConstantTimeSize is false. Constant-time otherwise.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type size() const\r
+ { return table_.size(); }\r
+\r
+ //! <b>Requires</b>: the hasher and the equality function unqualified swap\r
+ //! call should not throw.\r
+ //! \r
+ //! <b>Effects</b>: Swaps the contents of two iunordered_multisets.\r
+ //! Swaps also the contained bucket array and equality and hasher functors.\r
+ //!\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //!\r
+ //! <b>Throws</b>: If the swap() call for the comparison or hash functors\r
+ //! found using ADL throw. Basic guarantee.\r
+ void swap(iunordered_multiset& other)\r
+ { table_.swap(other.table_); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements from *this\r
+ //! calling Destroyer::operator()(pointer), clones all the \r
+ //! elements from src calling Cloner::operator()(const value_type &)\r
+ //! and inserts them on *this.\r
+ //!\r
+ //! If cloner throws, all cloned elements are unlinked and destroyed\r
+ //! calling Destroyer::operator()(pointer).\r
+ //! \r
+ //! <b>Complexity</b>: Linear to erased plus inserted elements.\r
+ //! \r
+ //! <b>Throws</b>: If cloner throws.\r
+ template <class Cloner, class Destroyer>\r
+ void clone_from(const iunordered_multiset &src, Cloner cloner, Destroyer destroyer)\r
+ { table_.clone_from(src.table_, cloner, destroyer); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue\r
+ //! \r
+ //! <b>Effects</b>: Inserts value into the iunordered_multiset.\r
+ //!\r
+ //! <b>Returns</b>: An iterator to the new inserted value.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.\r
+ //! \r
+ //! <b>Note</b>: Does not affect the validity of iterators and references.\r
+ //! No copy-constructors are called.\r
+ iterator insert(value_type &value)\r
+ { return table_.insert_equal(value); }\r
+\r
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue \r
+ //! of type value_type.\r
+ //! \r
+ //! <b>Effects</b>: Equivalent to this->insert(t) for each element in [b, e).\r
+ //! \r
+ //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the \r
+ //! size of the range. However, it is linear in N if the range is already sorted \r
+ //! by value_comp().\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Does not affect the validity of iterators and references.\r
+ //! No copy-constructors are called.\r
+ template<class Iterator>\r
+ void insert(Iterator b, Iterator e)\r
+ { table_.insert_equal(b, e); }\r
+\r
+ //! <b>Effects</b>: Erases the element pointed to by i. \r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased element. No destructors are called.\r
+ void erase(const_iterator i)\r
+ { table_.erase(i); }\r
+\r
+ //! <b>Effects</b>: Erases the range pointed to by b end e. \r
+ //! \r
+ //! <b>Complexity</b>: Average case O(std::distance(b, e)),\r
+ //! worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ void erase(const_iterator b, const_iterator e)\r
+ { table_.erase(b, e); }\r
+\r
+ //! <b>Effects</b>: Erases all the elements with the given value.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ size_type erase(const value_type &value)\r
+ { return table_.erase(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements that have the same hash and\r
+ //! compare equal with the given key.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the hasher or the equal functors throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ size_type erase(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.erase(key, hasher, equal); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases the element pointed to by i. \r
+ //! Destroyer::operator()(pointer) is called for the removed element.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators \r
+ //! to the erased elements.\r
+ template<class Destroyer>\r
+ void erase_and_destroy(const_iterator i, Destroyer destroyer)\r
+ { table_.erase_and_destroy(i, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases the range pointed to by b end e.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(std::distance(b, e)),\r
+ //! worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators\r
+ //! to the erased elements.\r
+ template<class Destroyer>\r
+ void erase_and_destroy(const_iterator b, const_iterator e, Destroyer destroyer)\r
+ { table_.erase_and_destroy(b, e, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements with the given value.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class Destroyer>\r
+ size_type erase_and_destroy(const value_type &value, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(value, destroyer); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //!\r
+ //! <b>Effects</b>: Erases all the elements with the given key.\r
+ //! according to the comparison functor "equal".\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //!\r
+ //! <b>Returns</b>: The number of erased elements.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)).\r
+ //! Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If hasher or equal throw. Basic guarantee.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators\r
+ //! to the erased elements.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual, class Destroyer>\r
+ size_type erase_and_destroy(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Destroyer destroyer)\r
+ { return table_.erase_and_destroy(key, hasher, equal, destroyer); }\r
+\r
+ //! <b>Effects</b>: Erases all the elements of the container.\r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements on the container.\r
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ void clear()\r
+ { return table_.clear(); }\r
+\r
+ //! <b>Requires</b>: Destroyer::operator()(pointer) shouldn't throw.\r
+ //! \r
+ //! <b>Effects</b>: Erases all the elements of the container.\r
+ //! \r
+ //! <b>Complexity</b>: Linear to the number of elements on the container.\r
+ //! Destroyer::operator()(pointer) is called for the removed elements.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: Invalidates the iterators (but not the references)\r
+ //! to the erased elements. No destructors are called.\r
+ template<class Destroyer>\r
+ void clear_and_destroy(Destroyer destroyer)\r
+ { return table_.clear_and_destroy(destroyer); }\r
+\r
+ //! <b>Effects</b>: Returns the number of contained elements with the given key\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ size_type count(const value_type &value) const\r
+ { return table_.count(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns the number of contained elements with the given key\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual, class Destroyer>\r
+ size_type count(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.count(key, hasher, equal); }\r
+\r
+ //! <b>Effects</b>: Finds an iterator to the first element whose value is \r
+ //! "value" or end() if that element does not exist.\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ iterator find(const value_type &value)\r
+ { return table_.find(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is \r
+ //! "key" according to the given hasher and equality functor or end() if\r
+ //! that element does not exist.\r
+ //!\r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ iterator find(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.find(key, hasher, equal); }\r
+\r
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is \r
+ //! "key" or end() if that element does not exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ const_iterator find(const value_type &value) const\r
+ { return table_.find(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is \r
+ //! "key" according to the given hasher and equality functor or end() if\r
+ //! that element does not exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(1), worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ const_iterator find(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.find(key, equal); }\r
+\r
+ //! <b>Effects</b>: Returns a range containing all elements with values equivalent\r
+ //! to value. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ std::pair<iterator,iterator> equal_range(const value_type &value)\r
+ { return table_.equal_range(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns a range containing all elements with equivalent\r
+ //! keys. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(key, hasher, equal)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hasher, KeyValueEqual equal)\r
+ { return table_.equal_range(key, hasher, equal); }\r
+\r
+ //! <b>Effects</b>: Returns a range containing all elements with values equivalent\r
+ //! to value. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ std::pair<const_iterator, const_iterator>\r
+ equal_range(const value_type &value) const\r
+ { return table_.equal_range(value); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! "key_value_equal" must be a equality function that induces \r
+ //! the same equality as key_equal. The difference is that\r
+ //! "key_value_equal" compares an arbitrary key with the contained values.\r
+ //!\r
+ //! <b>Effects</b>: Returns a range containing all elements with equivalent\r
+ //! keys. Returns std::make_pair(this->end(), this->end()) if no such \r
+ //! elements exist.\r
+ //! \r
+ //! <b>Complexity</b>: Average case O(this->count(key, hasher, equal)). Worst case O(this->size()).\r
+ //! \r
+ //! <b>Throws</b>: If the internal hasher or the equality functor throws.\r
+ //!\r
+ //! <b>Note</b>: This function is used when constructing a value_type\r
+ //! is expensive and the value_type can be compared with a cheaper\r
+ //! key type. Usually this key is part of the value_type.\r
+ template<class KeyType, class KeyHasher, class KeyValueEqual>\r
+ std::pair<const_iterator, const_iterator>\r
+ equal_range(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const\r
+ { return table_.equal_range(key, equal); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_multiset of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the iunordered_multiset\r
+ //! that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the hash function throws.\r
+ iterator current(value_type &value)\r
+ { return table_.current(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_multiset of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the\r
+ //! iunordered_multiset that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the hash function throws.\r
+ const_iterator current(const value_type &value) const\r
+ { return table_.current(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_multiset of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid local_iterator i belonging to the iunordered_multiset\r
+ //! that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static local_iterator current_local(value_type &value)\r
+ { return table_type::current_local(value); }\r
+\r
+ //! <b>Requires</b>: value must be an lvalue and shall be in a iunordered_multiset of\r
+ //! appropriate type. Otherwise the behavior is undefined.\r
+ //! \r
+ //! <b>Effects</b>: Returns: a valid const_local_iterator i belonging to\r
+ //! the iunordered_multiset that points to the value\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static const_local_iterator current_local(const value_type &value)\r
+ { return table_type::current_local(value); }\r
+\r
+ //! <b>Effects</b>: Returns the number of buckets passed in the constructor\r
+ //! or the last rehash function.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type bucket_count() const\r
+ { return table_.bucket_count(); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns the number of elements in the nth bucket.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ size_type bucket_size(size_type n)\r
+ { return table_.bucket_size(n); }\r
+\r
+ //! <b>Effects</b>: Returns the index of the bucket in which elements\r
+ //! with keys equivalent to k would be found, if any such element existed.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the hash functor throws.\r
+ //!\r
+ //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).\r
+ size_type bucket(const key_type& k)\r
+ { return table_.bucket(k); }\r
+\r
+ //! <b>Requires</b>: "hasher" must be a hash function that induces \r
+ //! the same hash values as the stored hasher. The difference is that\r
+ //! "hasher" hashes the given key instead of the value_type.\r
+ //!\r
+ //! <b>Effects</b>: Returns the index of the bucket in which elements\r
+ //! with keys equivalent to k would be found, if any such element existed.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: If the hash functor throws.\r
+ //!\r
+ //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).\r
+ template<class KeyType, class KeyHasher>\r
+ size_type bucket(const KeyType& k, const KeyHasher &hasher)\r
+ { return table_.bucket(k, hasher); }\r
+\r
+ //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor\r
+ //! or the last rehash function.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ bucket_ptr bucket_pointer() const\r
+ { return table_.bucket_pointer(); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a local_iterator pointing to the beginning\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ local_iterator begin(size_type n)\r
+ { return table_.begin(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ const_local_iterator begin(size_type n) const\r
+ { return table_.begin(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a local_iterator pointing to the end\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ local_iterator end(size_type n)\r
+ { return table_.end(n); }\r
+\r
+ //! <b>Requires</b>: n is in the range [0, this->bucket_count()).\r
+ //!\r
+ //! <b>Effects</b>: Returns a const_local_iterator pointing to the end\r
+ //! of the sequence stored in the bucket n.\r
+ //! \r
+ //! <b>Complexity</b>: Constant.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ //! \r
+ //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range\r
+ //! containing all of the elements in the nth bucket. \r
+ const_local_iterator end(size_type n) const\r
+ { return table_.end(n); }\r
+\r
+ //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array\r
+ //! or the same as the old bucket array. new_size is the length of the\r
+ //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer()\r
+ //! n can be bigger or smaller than this->bucket_count().\r
+ //!\r
+ //! <b>Effects</b>: Updates the internal reference with the new bucket erases\r
+ //! the values from the old bucket and inserts then in the new one. \r
+ //! \r
+ //! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic.\r
+ //! \r
+ //! <b>Throws</b>: If the hasher functor throws.\r
+ void rehash(bucket_ptr new_buckets, size_type new_size)\r
+ { table_.rehash(new_buckets, new_size); }\r
+\r
+ //! <b>Effects</b>: Returns the nearest new bucket count optimized for\r
+ //! the container that is bigger than n. This suggestion can be used\r
+ //! to create bucket arrays with a size that will usually improve\r
+ //! container's performance. If such value does not exist, the \r
+ //! higher possible value is returned.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static size_type suggested_upper_bucket_count(size_type n)\r
+ { return table_type::suggested_upper_bucket_count(n); }\r
+\r
+ //! <b>Effects</b>: Returns the nearest new bucket count optimized for\r
+ //! the container that is smaller than n. This suggestion can be used\r
+ //! to create bucket arrays with a size that will usually improve\r
+ //! container's performance. If such value does not exist, the \r
+ //! lower possible value is returned.\r
+ //! \r
+ //! <b>Complexity</b>: Amortized constant time.\r
+ //! \r
+ //! <b>Throws</b>: Nothing.\r
+ static size_type suggested_lower_bucket_count(size_type n)\r
+ { return table_type::suggested_lower_bucket_count(n); }\r
+};\r
+\r
+} //namespace intrusive \r
+} //namespace boost \r
+\r
+#include "detail/config_end.hpp"\r
+\r
+#endif //BOOST_INTRUSIVE_IHASHSET_HPP\r