Reference
Header <<ulink url="../../boost/unordered_set.hpp">boost/unordered_set.hpp</ulink>>namespace boost { template<typename Value, typename Hash = boost::hash<Value>, typename Pred = std::equal_to<Value>, typename Alloc = std::allocator<Value> > class unordered_set; template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_set<Value, Hash, Pred, Alloc> const&, unordered_set<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_set<Value, Hash, Pred, Alloc> const&, unordered_set<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_set<Value, Hash, Pred, Alloc>&, unordered_set<Value, Hash, Pred, Alloc>&); template<typename Value, typename Hash = boost::hash<Value>, typename Pred = std::equal_to<Value>, typename Alloc = std::allocator<Value> > class unordered_multiset; template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multiset<Value, Hash, Pred, Alloc> const&, unordered_multiset<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multiset<Value, Hash, Pred, Alloc> const&, unordered_multiset<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_multiset<Value, Hash, Pred, Alloc>&, unordered_multiset<Value, Hash, Pred, Alloc>&); } Class template unordered_set3boost::unordered_set An unordered associative container that stores unique values. // In header: <boost/unordered_set.hpp> template<typename Value, typename Hash = boost::hash<Value>, typename Pred = std::equal_to<Value>, typename Alloc = std::allocator<Value> > class unordered_set { public: // types typedef Value key_type; typedef Value value_type; typedef Hash hasher; typedef Pred key_equal; typedef Alloc allocator_type; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename allocator_type::reference reference; // lvalue of value_type. typedef typename allocator_type::const_reference const_reference; // const lvalue of value_type. typedef implementation-defined size_type; typedef implementation-defined difference_type; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef implementation-defined local_iterator; typedef implementation-defined const_local_iterator; // construct/copy/destruct explicit unordered_set(size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); template<typename InputIterator> unordered_set(InputIterator, InputIterator, size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); unordered_set(unordered_set const&); unordered_set(unordered_set &&); explicit unordered_set(Allocator const&); unordered_set(unordered_set const&, Allocator const&); ~unordered_set(); unordered_set& operator=(unordered_set const&); unordered_set& operator=(unordered_set &&); allocator_type get_allocator() const; // size and capacity bool empty() const; size_type size() const; size_type max_size() const; // iterators iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; const_iterator cbegin() const; const_iterator cend() const; // modifiers template<typename... Args> std::pair<iterator, bool> emplace(Args&&...); template<typename... Args> iterator emplace_hint(const_iterator, Args&&...); std::pair<iterator, bool> insert(value_type const&); iterator insert(const_iterator, value_type const&); template<typename InputIterator> void insert(InputIterator, InputIterator); iterator erase(const_iterator); size_type erase(key_type const&); iterator erase(const_iterator, const_iterator); void quick_erase(const_iterator); void erase_return_void(const_iterator); void clear(); void swap(unordered_set&); // observers hasher hash_function() const; key_equal key_eq() const; // lookup iterator find(key_type const&); const_iterator find(key_type const&) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&) const; size_type count(key_type const&) const; std::pair<iterator, iterator> equal_range(key_type const&); std::pair<const_iterator, const_iterator> equal_range(key_type const&) const; // bucket interface size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type) const; size_type bucket(key_type const&) const; local_iterator begin(size_type); const_local_iterator begin(size_type) const; local_iterator end(size_type); const_local_iterator end(size_type) const; const_local_iterator cbegin(size_type) const; const_local_iterator cend(size_type); // hash policy float load_factor() const; float max_load_factor() const; void max_load_factor(float); void rehash(size_type); }; // Equality Comparisons template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_set<Value, Hash, Pred, Alloc> const&, unordered_set<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_set<Value, Hash, Pred, Alloc> const&, unordered_set<Value, Hash, Pred, Alloc> const&); // swap template<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_set<Value, Hash, Pred, Alloc>&, unordered_set<Value, Hash, Pred, Alloc>&);Description Based on chapter 23 of the working draft of the C++ standard [n2960]. But without the updated rules for allocators. Template Parameters Value Value must be Assignable and CopyConstructible Hash A unary function object type that acts a hash function for a Value. It takes a single argument of type Value and returns a value of type std::size_t. Pred A binary function object that implements an equivalence relation on values of type Value. A binary function object that induces an equivalence relation on values of type Key. It takes two arguments of type Key and returns a value of type bool. Alloc An allocator whose value type is the same as the container's value type. The elements are organized into buckets. Keys with the same hash code are stored in the same bucket. The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash. <anchor id="boost.unordered_settypes"/><computeroutput>unordered_set</computeroutput> public types typedef implementation-defined size_type; An unsigned integral type. size_type can represent any non-negative value of difference_type. typedef implementation-defined difference_type; A signed integral type. Is identical to the difference type of iterator and const_iterator. typedef implementation-defined iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. Convertible to const_iterator. typedef implementation-defined const_iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. typedef implementation-defined local_iterator; An iterator with the same value type, difference type and pointer and reference type as iterator. A local_iterator object can be used to iterate through a single bucket. typedef implementation-defined const_local_iterator; A constant iterator with the same value type, difference type and pointer and reference type as const_iterator. A const_local_iterator object can be used to iterate through a single bucket. <anchor id="boost.unordered_setconstruct-copy-destruct"/><computeroutput>unordered_set</computeroutput> public construct/copy/destructexplicit unordered_set(size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.Postconditions:size() == 0template<typename InputIterator> unordered_set(InputIterator f, InputIterator l, size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.unordered_set(unordered_set const&);The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.Requires:value_type is copy constructibleunordered_set(unordered_set &&);The move constructor.Notes:This is emulated on compilers without rvalue references.Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). explicit unordered_set(Allocator const& a);Constructs an empty container, using allocator a.unordered_set(unordered_set const& x, Allocator const& a);Constructs an container, copying x's contained elements, hash function, predicate, maximum load factor, but using allocator a.~unordered_set();Notes:The destructor is applied to every element, and all memory is deallocatedunordered_set& operator=(unordered_set const&);The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_set) in order to emulate move semantics. Requires:value_type is copy constructibleunordered_set& operator=(unordered_set &&);The move assignment operator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_set) in order to emulate move semantics. Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). allocator_type get_allocator() const;<anchor id="id11-bb"/><computeroutput>unordered_set</computeroutput> size and capacitybool empty() const;Returns:size() == 0size_type size() const;Returns:std::distance(begin(), end())size_type max_size() const;Returns:size() of the largest possible container. <anchor id="id15-bb"/><computeroutput>unordered_set</computeroutput> iteratorsiterator begin(); const_iterator begin() const;Returns:An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. iterator end(); const_iterator end() const;Returns:An iterator which refers to the past-the-end value for the container. const_iterator cbegin() const;Returns:A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. const_iterator cend() const;Returns:A constant iterator which refers to the past-the-end value for the container. <anchor id="id24-bb"/><computeroutput>unordered_set</computeroutput> modifierstemplate<typename... Args> std::pair<iterator, bool> emplace(Args&&... args);Inserts an object, constructed with the arguments args, in the container if and only if there is no element in the container with an equivalent value.Returns:The bool component of the return type is true if an insert took place.If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.template<typename... Args> iterator emplace_hint(const_iterator hint, Args&&... args);Inserts an object, constructed with the arguments args, in the container if and only if there is no element in the container with an equivalent value.hint is a suggestion to where the element should be inserted.Returns:If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.std::pair<iterator, bool> insert(value_type const& obj);Inserts obj in the container if and only if there is no element in the container with an equivalent value.Returns:The bool component of the return type is true if an insert took place.If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator insert(const_iterator hint, value_type const& obj);Inserts obj in the container if and only if there is no element in the container with an equivalent value.hint is a suggestion to where the element should be inserted.Returns:If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.template<typename InputIterator> void insert(InputIterator first, InputIterator last);Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent value.Throws:When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator erase(const_iterator position);Erase the element pointed to by position.Returns:The iterator following position before the erasure.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: When the number of elements is a lot smaller than the number of buckets this function can be very inefficient as it has to search through empty buckets for the next element, in order to return the iterator. The method quick_erase is faster, but has yet to be standardized. size_type erase(key_type const& k);Erase all elements with key equivalent to k.Returns:The number of elements erased.Throws:Only throws an exception if it is thrown by hasher or key_equal.iterator erase(const_iterator first, const_iterator last);Erases the elements in the range from first to last.Returns:The iterator following the erased elements - i.e. last.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.void quick_erase(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is faster than erase as it doesn't have to find the next element in the container - a potentially costly operation. As it hasn't been standardized, it's likely that this may change in the future. void erase_return_void(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is now deprecated, use quick_return instead. Although be warned that as that isn't standardized yet, it could also change. void clear();Erases all elements in the container.Postconditions:size() == 0Throws:Never throws an exception.void swap(unordered_set&);Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.<anchor id="id37-bb"/><computeroutput>unordered_set</computeroutput> observershasher hash_function() const;Returns:The container's hash function. key_equal key_eq() const;Returns:The container's key equality predicate. <anchor id="id40-bb"/><computeroutput>unordered_set</computeroutput> lookupiterator find(key_type const& k); const_iterator find(key_type const& k) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq) const;Returns:An iterator pointing to an element with key equivalent to k, or b.end() if no such element exists.Notes: The templated overloads are a non-standard extensions which allows you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged. size_type count(key_type const& k) const;Returns:The number of elements with key equivalent to k.std::pair<iterator, iterator> equal_range(key_type const& k); std::pair<const_iterator, const_iterator> equal_range(key_type const& k) const;Returns:A range containing all elements with key equivalent to k. If the container doesn't container any such elements, returns std::make_pair(b.end(),b.end()). <anchor id="id50-bb"/><computeroutput>unordered_set</computeroutput> bucket interfacesize_type bucket_count() const;Returns:The number of buckets.size_type max_bucket_count() const;Returns:An upper bound on the number of buckets.size_type bucket_size(size_type n) const;Requires:n < bucket_count()Returns:The number of elements in bucket n.size_type bucket(key_type const& k) const;Returns:The index of the bucket which would contain an element with key k.Postconditions:The return value is less than bucket_count()local_iterator begin(size_type n); const_local_iterator begin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the first element in the bucket with index n.local_iterator end(size_type n); const_local_iterator end(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the 'one past the end' element in the bucket with index n.const_local_iterator cbegin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the first element in the bucket with index n.const_local_iterator cend(size_type n);Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the 'one past the end' element in the bucket with index n.<anchor id="id63-bb"/><computeroutput>unordered_set</computeroutput> hash policyfloat load_factor() const;Returns:The average number of elements per bucket.float max_load_factor() const;Returns:Returns the current maximum load factor.void max_load_factor(float z);Effects:Changes the container's maximum load factor, using z as a hint.void rehash(size_type n);Changes the number of buckets so that there at least n buckets, and so that the load factor is less than the maximum load factor.Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.Throws:The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.<anchor id="id68-bb"/><computeroutput>unordered_set</computeroutput> Equality Comparisonstemplate<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_set<Value, Hash, Pred, Alloc> const& x, unordered_set<Value, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_set<Value, Hash, Pred, Alloc> const& x, unordered_set<Value, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.<anchor id="id69-bb"/><computeroutput>unordered_set</computeroutput> swaptemplate<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_set<Value, Hash, Pred, Alloc>& x, unordered_set<Value, Hash, Pred, Alloc>& y);Effects:x.swap(y)Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of Hash or Pred.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.Class template unordered_multiset3boost::unordered_multiset An unordered associative container that stores values. The same key can be stored multiple times. // In header: <boost/unordered_set.hpp> template<typename Value, typename Hash = boost::hash<Value>, typename Pred = std::equal_to<Value>, typename Alloc = std::allocator<Value> > class unordered_multiset { public: // types typedef Value key_type; typedef Value value_type; typedef Hash hasher; typedef Pred key_equal; typedef Alloc allocator_type; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename allocator_type::reference reference; // lvalue of value_type. typedef typename allocator_type::const_reference const_reference; // const lvalue of value_type. typedef implementation-defined size_type; typedef implementation-defined difference_type; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef implementation-defined local_iterator; typedef implementation-defined const_local_iterator; // construct/copy/destruct explicit unordered_multiset(size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); template<typename InputIterator> unordered_multiset(InputIterator, InputIterator, size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); unordered_multiset(unordered_multiset const&); unordered_multiset(unordered_multiset &&); explicit unordered_multiset(Allocator const&); unordered_multiset(unordered_multiset const&, Allocator const&); ~unordered_multiset(); unordered_multiset& operator=(unordered_multiset const&); unordered_multiset& operator=(unordered_multiset &&); allocator_type get_allocator() const; // size and capacity bool empty() const; size_type size() const; size_type max_size() const; // iterators iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; const_iterator cbegin() const; const_iterator cend() const; // modifiers template<typename... Args> iterator emplace(Args&&...); template<typename... Args> iterator emplace_hint(const_iterator, Args&&...); iterator insert(value_type const&); iterator insert(const_iterator, value_type const&); template<typename InputIterator> void insert(InputIterator, InputIterator); iterator erase(const_iterator); size_type erase(key_type const&); iterator erase(const_iterator, const_iterator); void quick_erase(const_iterator); void erase_return_void(const_iterator); void clear(); void swap(unordered_multiset&); // observers hasher hash_function() const; key_equal key_eq() const; // lookup iterator find(key_type const&); const_iterator find(key_type const&) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&) const; size_type count(key_type const&) const; std::pair<iterator, iterator> equal_range(key_type const&); std::pair<const_iterator, const_iterator> equal_range(key_type const&) const; // bucket interface size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type) const; size_type bucket(key_type const&) const; local_iterator begin(size_type); const_local_iterator begin(size_type) const; local_iterator end(size_type); const_local_iterator end(size_type) const; const_local_iterator cbegin(size_type) const; const_local_iterator cend(size_type); // hash policy float load_factor() const; float max_load_factor() const; void max_load_factor(float); void rehash(size_type); }; // Equality Comparisons template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multiset<Value, Hash, Pred, Alloc> const&, unordered_multiset<Value, Hash, Pred, Alloc> const&); template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multiset<Value, Hash, Pred, Alloc> const&, unordered_multiset<Value, Hash, Pred, Alloc> const&); // swap template<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_multiset<Value, Hash, Pred, Alloc>&, unordered_multiset<Value, Hash, Pred, Alloc>&);Description Based on chapter 23 of the working draft of the C++ standard [n2960]. But without the updated rules for allocators. Template Parameters Value Value must be Assignable and CopyConstructible Hash A unary function object type that acts a hash function for a Value. It takes a single argument of type Value and returns a value of type std::size_t. Pred A binary function object that implements an equivalence relation on values of type Value. A binary function object that induces an equivalence relation on values of type Key. It takes two arguments of type Key and returns a value of type bool. Alloc An allocator whose value type is the same as the container's value type. The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other. The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash. <anchor id="boost.unordered_multisettypes"/><computeroutput>unordered_multiset</computeroutput> public types typedef implementation-defined size_type; An unsigned integral type. size_type can represent any non-negative value of difference_type. typedef implementation-defined difference_type; A signed integral type. Is identical to the difference type of iterator and const_iterator. typedef implementation-defined iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. Convertible to const_iterator. typedef implementation-defined const_iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. typedef implementation-defined local_iterator; An iterator with the same value type, difference type and pointer and reference type as iterator. A local_iterator object can be used to iterate through a single bucket. typedef implementation-defined const_local_iterator; A constant iterator with the same value type, difference type and pointer and reference type as const_iterator. A const_local_iterator object can be used to iterate through a single bucket. <anchor id="boost.unordered_multisetconstruct-copy-destruct"/><computeroutput>unordered_multiset</computeroutput> public construct/copy/destructexplicit unordered_multiset(size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.Postconditions:size() == 0template<typename InputIterator> unordered_multiset(InputIterator f, InputIterator l, size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.unordered_multiset(unordered_multiset const&);The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.Requires:value_type is copy constructibleunordered_multiset(unordered_multiset &&);The move constructor.Notes:This is emulated on compilers without rvalue references.Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). explicit unordered_multiset(Allocator const& a);Constructs an empty container, using allocator a.unordered_multiset(unordered_multiset const& x, Allocator const& a);Constructs an container, copying x's contained elements, hash function, predicate, maximum load factor, but using allocator a.~unordered_multiset();Notes:The destructor is applied to every element, and all memory is deallocatedunordered_multiset& operator=(unordered_multiset const&);The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_multiset) in order to emulate move semantics. Requires:value_type is copy constructibleunordered_multiset& operator=(unordered_multiset &&);The move assignment operator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_multiset) in order to emulate move semantics. Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). allocator_type get_allocator() const;<anchor id="id80-bb"/><computeroutput>unordered_multiset</computeroutput> size and capacitybool empty() const;Returns:size() == 0size_type size() const;Returns:std::distance(begin(), end())size_type max_size() const;Returns:size() of the largest possible container. <anchor id="id84-bb"/><computeroutput>unordered_multiset</computeroutput> iteratorsiterator begin(); const_iterator begin() const;Returns:An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. iterator end(); const_iterator end() const;Returns:An iterator which refers to the past-the-end value for the container. const_iterator cbegin() const;Returns:A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. const_iterator cend() const;Returns:A constant iterator which refers to the past-the-end value for the container. <anchor id="id93-bb"/><computeroutput>unordered_multiset</computeroutput> modifierstemplate<typename... Args> iterator emplace(Args&&... args);Inserts an object, constructed with the arguments args, in the container.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.template<typename... Args> iterator emplace_hint(const_iterator hint, Args&&... args);Inserts an object, constructed with the arguments args, in the container.hint is a suggestion to where the element should be inserted.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.iterator insert(value_type const& obj);Inserts obj in the container.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator insert(const_iterator hint, value_type const& obj);Inserts obj in the container.hint is a suggestion to where the element should be inserted.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.template<typename InputIterator> void insert(InputIterator first, InputIterator last);Inserts a range of elements into the container.Throws:When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator erase(const_iterator position);Erase the element pointed to by position.Returns:The iterator following position before the erasure.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: When the number of elements is a lot smaller than the number of buckets this function can be very inefficient as it has to search through empty buckets for the next element, in order to return the iterator. The method quick_erase is faster, but has yet to be standardized. size_type erase(key_type const& k);Erase all elements with key equivalent to k.Returns:The number of elements erased.Throws:Only throws an exception if it is thrown by hasher or key_equal.iterator erase(const_iterator first, const_iterator last);Erases the elements in the range from first to last.Returns:The iterator following the erased elements - i.e. last.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.void quick_erase(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is faster than erase as it doesn't have to find the next element in the container - a potentially costly operation. As it hasn't been standardized, it's likely that this may change in the future. void erase_return_void(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is now deprecated, use quick_return instead. Although be warned that as that isn't standardized yet, it could also change. void clear();Erases all elements in the container.Postconditions:size() == 0Throws:Never throws an exception.void swap(unordered_multiset&);Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.<anchor id="id106-bb"/><computeroutput>unordered_multiset</computeroutput> observershasher hash_function() const;Returns:The container's hash function. key_equal key_eq() const;Returns:The container's key equality predicate. <anchor id="id109-bb"/><computeroutput>unordered_multiset</computeroutput> lookupiterator find(key_type const& k); const_iterator find(key_type const& k) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq) const;Returns:An iterator pointing to an element with key equivalent to k, or b.end() if no such element exists.Notes: The templated overloads are a non-standard extensions which allows you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged. size_type count(key_type const& k) const;Returns:The number of elements with key equivalent to k.std::pair<iterator, iterator> equal_range(key_type const& k); std::pair<const_iterator, const_iterator> equal_range(key_type const& k) const;Returns:A range containing all elements with key equivalent to k. If the container doesn't container any such elements, returns std::make_pair(b.end(),b.end()). <anchor id="id119-bb"/><computeroutput>unordered_multiset</computeroutput> bucket interfacesize_type bucket_count() const;Returns:The number of buckets.size_type max_bucket_count() const;Returns:An upper bound on the number of buckets.size_type bucket_size(size_type n) const;Requires:n < bucket_count()Returns:The number of elements in bucket n.size_type bucket(key_type const& k) const;Returns:The index of the bucket which would contain an element with key k.Postconditions:The return value is less than bucket_count()local_iterator begin(size_type n); const_local_iterator begin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the first element in the bucket with index n.local_iterator end(size_type n); const_local_iterator end(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the 'one past the end' element in the bucket with index n.const_local_iterator cbegin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the first element in the bucket with index n.const_local_iterator cend(size_type n);Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the 'one past the end' element in the bucket with index n.<anchor id="id132-bb"/><computeroutput>unordered_multiset</computeroutput> hash policyfloat load_factor() const;Returns:The average number of elements per bucket.float max_load_factor() const;Returns:Returns the current maximum load factor.void max_load_factor(float z);Effects:Changes the container's maximum load factor, using z as a hint.void rehash(size_type n);Changes the number of buckets so that there at least n buckets, and so that the load factor is less than the maximum load factor.Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.Throws:The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.<anchor id="id137-bb"/><computeroutput>unordered_multiset</computeroutput> Equality Comparisonstemplate<typename Value, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multiset<Value, Hash, Pred, Alloc> const& x, unordered_multiset<Value, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.template<typename Value, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multiset<Value, Hash, Pred, Alloc> const& x, unordered_multiset<Value, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.<anchor id="id138-bb"/><computeroutput>unordered_multiset</computeroutput> swaptemplate<typename Value, typename Hash, typename Pred, typename Alloc> void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x, unordered_multiset<Value, Hash, Pred, Alloc>& y);Effects:x.swap(y)Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of Hash or Pred.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.
Header <<ulink url="../../boost/unordered_map.hpp">boost/unordered_map.hpp</ulink>>namespace boost { template<typename Key, typename Mapped, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>, typename Alloc = std::allocator<std::pair<Key const, Mapped> > > class unordered_map; template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_map<Key, Mapped, Hash, Pred, Alloc> const&, unordered_map<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_map<Key, Mapped, Hash, Pred, Alloc> const&, unordered_map<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_map<Key, Mapped, Hash, Pred, Alloc>&, unordered_map<Key, Mapped, Hash, Pred, Alloc>&); template<typename Key, typename Mapped, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>, typename Alloc = std::allocator<std::pair<Key const, Mapped> > > class unordered_multimap; template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&); } Class template unordered_map3boost::unordered_map An unordered associative container that associates unique keys with another value. // In header: <boost/unordered_map.hpp> template<typename Key, typename Mapped, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>, typename Alloc = std::allocator<std::pair<Key const, Mapped> > > class unordered_map { public: // types typedef Key key_type; typedef std::pair<Key const, Mapped> value_type; typedef Mapped mapped_type; typedef Hash hasher; typedef Pred key_equal; typedef Alloc allocator_type; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename allocator_type::reference reference; // lvalue of value_type. typedef typename allocator_type::const_reference const_reference; // const lvalue of value_type. typedef implementation-defined size_type; typedef implementation-defined difference_type; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef implementation-defined local_iterator; typedef implementation-defined const_local_iterator; // construct/copy/destruct explicit unordered_map(size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); template<typename InputIterator> unordered_map(InputIterator, InputIterator, size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); unordered_map(unordered_map const&); unordered_map(unordered_map &&); explicit unordered_map(Allocator const&); unordered_map(unordered_map const&, Allocator const&); ~unordered_map(); unordered_map& operator=(unordered_map const&); unordered_map& operator=(unordered_map &&); allocator_type get_allocator() const; // size and capacity bool empty() const; size_type size() const; size_type max_size() const; // iterators iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; const_iterator cbegin() const; const_iterator cend() const; // modifiers template<typename... Args> std::pair<iterator, bool> emplace(Args&&...); template<typename... Args> iterator emplace_hint(const_iterator, Args&&...); std::pair<iterator, bool> insert(value_type const&); iterator insert(const_iterator, value_type const&); template<typename InputIterator> void insert(InputIterator, InputIterator); iterator erase(const_iterator); size_type erase(key_type const&); iterator erase(const_iterator, const_iterator); void quick_erase(const_iterator); void erase_return_void(const_iterator); void clear(); void swap(unordered_map&); // observers hasher hash_function() const; key_equal key_eq() const; // lookup iterator find(key_type const&); const_iterator find(key_type const&) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&) const; size_type count(key_type const&) const; std::pair<iterator, iterator> equal_range(key_type const&); std::pair<const_iterator, const_iterator> equal_range(key_type const&) const; mapped_type& operator[](key_type const&); Mapped& at(key_type const&); Mapped const& at(key_type const&) const; // bucket interface size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type) const; size_type bucket(key_type const&) const; local_iterator begin(size_type); const_local_iterator begin(size_type) const; local_iterator end(size_type); const_local_iterator end(size_type) const; const_local_iterator cbegin(size_type) const; const_local_iterator cend(size_type); // hash policy float load_factor() const; float max_load_factor() const; void max_load_factor(float); void rehash(size_type); }; // Equality Comparisons template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_map<Key, Mapped, Hash, Pred, Alloc> const&, unordered_map<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_map<Key, Mapped, Hash, Pred, Alloc> const&, unordered_map<Key, Mapped, Hash, Pred, Alloc> const&); // swap template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_map<Key, Mapped, Hash, Pred, Alloc>&, unordered_map<Key, Mapped, Hash, Pred, Alloc>&);Description Based on chapter 23 of the working draft of the C++ standard [n2960]. But without the updated rules for allocators. Template Parameters Key Key must be Assignable and CopyConstructible. Mapped Mapped must be CopyConstructible Hash A unary function object type that acts a hash function for a Key. It takes a single argument of type Key and returns a value of type std::size_t. Pred A binary function object that implements an equivalence relation on values of type Key. A binary function object that induces an equivalence relation on values of type Key. It takes two arguments of type Key and returns a value of type bool. Alloc An allocator whose value type is the same as the container's value type. The elements are organized into buckets. Keys with the same hash code are stored in the same bucket. The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash. <anchor id="boost.unordered_maptypes"/><computeroutput>unordered_map</computeroutput> public types typedef implementation-defined size_type; An unsigned integral type. size_type can represent any non-negative value of difference_type. typedef implementation-defined difference_type; A signed integral type. Is identical to the difference type of iterator and const_iterator. typedef implementation-defined iterator; A iterator whose value type is value_type. The iterator category is at least a forward iterator. Convertible to const_iterator. typedef implementation-defined const_iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. typedef implementation-defined local_iterator; An iterator with the same value type, difference type and pointer and reference type as iterator. A local_iterator object can be used to iterate through a single bucket. typedef implementation-defined const_local_iterator; A constant iterator with the same value type, difference type and pointer and reference type as const_iterator. A const_local_iterator object can be used to iterate through a single bucket. <anchor id="boost.unordered_mapconstruct-copy-destruct"/><computeroutput>unordered_map</computeroutput> public construct/copy/destructexplicit unordered_map(size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.Postconditions:size() == 0template<typename InputIterator> unordered_map(InputIterator f, InputIterator l, size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.unordered_map(unordered_map const&);The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.Requires:value_type is copy constructibleunordered_map(unordered_map &&);The move constructor.Notes:This is emulated on compilers without rvalue references.Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). explicit unordered_map(Allocator const& a);Constructs an empty container, using allocator a.unordered_map(unordered_map const& x, Allocator const& a);Constructs an container, copying x's contained elements, hash function, predicate, maximum load factor, but using allocator a.~unordered_map();Notes:The destructor is applied to every element, and all memory is deallocatedunordered_map& operator=(unordered_map const&);The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_map) in order to emulate move semantics. Requires:value_type is copy constructibleunordered_map& operator=(unordered_map &&);The move assignment operator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_map) in order to emulate move semantics. Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). allocator_type get_allocator() const;<anchor id="id149-bb"/><computeroutput>unordered_map</computeroutput> size and capacitybool empty() const;Returns:size() == 0size_type size() const;Returns:std::distance(begin(), end())size_type max_size() const;Returns:size() of the largest possible container. <anchor id="id153-bb"/><computeroutput>unordered_map</computeroutput> iteratorsiterator begin(); const_iterator begin() const;Returns:An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. iterator end(); const_iterator end() const;Returns:An iterator which refers to the past-the-end value for the container. const_iterator cbegin() const;Returns:A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. const_iterator cend() const;Returns:A constant iterator which refers to the past-the-end value for the container. <anchor id="id162-bb"/><computeroutput>unordered_map</computeroutput> modifierstemplate<typename... Args> std::pair<iterator, bool> emplace(Args&&... args);Inserts an object, constructed with the arguments args, in the container if and only if there is no element in the container with an equivalent key.Returns:The bool component of the return type is true if an insert took place.If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.template<typename... Args> iterator emplace_hint(const_iterator hint, Args&&... args);Inserts an object, constructed with the arguments args, in the container if and only if there is no element in the container with an equivalent key.hint is a suggestion to where the element should be inserted.Returns:If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.std::pair<iterator, bool> insert(value_type const& obj);Inserts obj in the container if and only if there is no element in the container with an equivalent key.Returns:The bool component of the return type is true if an insert took place.If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator insert(const_iterator hint, value_type const& obj);Inserts obj in the container if and only if there is no element in the container with an equivalent key.hint is a suggestion to where the element should be inserted.Returns:If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.template<typename InputIterator> void insert(InputIterator first, InputIterator last);Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.Throws:When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator erase(const_iterator position);Erase the element pointed to by position.Returns:The iterator following position before the erasure.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: When the number of elements is a lot smaller than the number of buckets this function can be very inefficient as it has to search through empty buckets for the next element, in order to return the iterator. The method quick_erase is faster, but has yet to be standardized. size_type erase(key_type const& k);Erase all elements with key equivalent to k.Returns:The number of elements erased.Throws:Only throws an exception if it is thrown by hasher or key_equal.iterator erase(const_iterator first, const_iterator last);Erases the elements in the range from first to last.Returns:The iterator following the erased elements - i.e. last.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.void quick_erase(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is faster than erase as it doesn't have to find the next element in the container - a potentially costly operation. As it hasn't been standardized, it's likely that this may change in the future. void erase_return_void(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is now deprecated, use quick_return instead. Although be warned that as that isn't standardized yet, it could also change. void clear();Erases all elements in the container.Postconditions:size() == 0Throws:Never throws an exception.void swap(unordered_map&);Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.<anchor id="id175-bb"/><computeroutput>unordered_map</computeroutput> observershasher hash_function() const;Returns:The container's hash function. key_equal key_eq() const;Returns:The container's key equality predicate. <anchor id="id178-bb"/><computeroutput>unordered_map</computeroutput> lookupiterator find(key_type const& k); const_iterator find(key_type const& k) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq) const;Returns:An iterator pointing to an element with key equivalent to k, or b.end() if no such element exists.Notes: The templated overloads are a non-standard extensions which allows you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged. size_type count(key_type const& k) const;Returns:The number of elements with key equivalent to k.std::pair<iterator, iterator> equal_range(key_type const& k); std::pair<const_iterator, const_iterator> equal_range(key_type const& k) const;Returns:A range containing all elements with key equivalent to k. If the container doesn't container any such elements, returns std::make_pair(b.end(),b.end()). mapped_type& operator[](key_type const& k);Effects:If the container does not already contain an elements with a key equivalent to k, inserts the value std::pair<key_type const, mapped_type>(k, mapped_type())Returns:A reference to x.second where x is the element already in the container, or the newly inserted element with a key equivalent to kThrows:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.Mapped& at(key_type const& k); Mapped const& at(key_type const& k) const;Returns:A reference to x.second where x is the (unique) element whose key is equivalent to k.Throws:An exception object of type std::out_of_range if no such element is present.Notes:This is not specified in the draft standard, but that is probably an oversight. The issue has been raised in comp.std.c++.<anchor id="id192-bb"/><computeroutput>unordered_map</computeroutput> bucket interfacesize_type bucket_count() const;Returns:The number of buckets.size_type max_bucket_count() const;Returns:An upper bound on the number of buckets.size_type bucket_size(size_type n) const;Requires:n < bucket_count()Returns:The number of elements in bucket n.size_type bucket(key_type const& k) const;Returns:The index of the bucket which would contain an element with key k.Postconditions:The return value is less than bucket_count()local_iterator begin(size_type n); const_local_iterator begin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the first element in the bucket with index n.local_iterator end(size_type n); const_local_iterator end(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the 'one past the end' element in the bucket with index n.const_local_iterator cbegin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the first element in the bucket with index n.const_local_iterator cend(size_type n);Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the 'one past the end' element in the bucket with index n.<anchor id="id205-bb"/><computeroutput>unordered_map</computeroutput> hash policyfloat load_factor() const;Returns:The average number of elements per bucket.float max_load_factor() const;Returns:Returns the current maximum load factor.void max_load_factor(float z);Effects:Changes the container's maximum load factor, using z as a hint.void rehash(size_type n);Changes the number of buckets so that there at least n buckets, and so that the load factor is less than the maximum load factor.Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.Throws:The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.<anchor id="id210-bb"/><computeroutput>unordered_map</computeroutput> Equality Comparisonstemplate<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_map<Key, Mapped, Hash, Pred, Alloc> const& x, unordered_map<Key, Mapped, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_map<Key, Mapped, Hash, Pred, Alloc> const& x, unordered_map<Key, Mapped, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.<anchor id="id211-bb"/><computeroutput>unordered_map</computeroutput> swaptemplate<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_map<Key, Mapped, Hash, Pred, Alloc>& x, unordered_map<Key, Mapped, Hash, Pred, Alloc>& y);Effects:x.swap(y)Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of Hash or Pred.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.Class template unordered_multimap3boost::unordered_multimap An unordered associative container that associates keys with another value. The same key can be stored multiple times. // In header: <boost/unordered_map.hpp> template<typename Key, typename Mapped, typename Hash = boost::hash<Key>, typename Pred = std::equal_to<Key>, typename Alloc = std::allocator<std::pair<Key const, Mapped> > > class unordered_multimap { public: // types typedef Key key_type; typedef std::pair<Key const, Mapped> value_type; typedef Mapped mapped_type; typedef Hash hasher; typedef Pred key_equal; typedef Alloc allocator_type; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename allocator_type::reference reference; // lvalue of value_type. typedef typename allocator_type::const_reference const_reference; // const lvalue of value_type. typedef implementation-defined size_type; typedef implementation-defined difference_type; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef implementation-defined local_iterator; typedef implementation-defined const_local_iterator; // construct/copy/destruct explicit unordered_multimap(size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); template<typename InputIterator> unordered_multimap(InputIterator, InputIterator, size_type = implementation-defined, hasher const& = hasher(), key_equal const& = key_equal(), allocator_type const& = allocator_type()); unordered_multimap(unordered_multimap const&); unordered_multimap(unordered_multimap &&); explicit unordered_multimap(Allocator const&); unordered_multimap(unordered_multimap const&, Allocator const&); ~unordered_multimap(); unordered_multimap& operator=(unordered_multimap const&); unordered_multimap& operator=(unordered_multimap &&); allocator_type get_allocator() const; // size and capacity bool empty() const; size_type size() const; size_type max_size() const; // iterators iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; const_iterator cbegin() const; const_iterator cend() const; // modifiers template<typename... Args> iterator emplace(Args&&...); template<typename... Args> iterator emplace_hint(const_iterator, Args&&...); iterator insert(value_type const&); iterator insert(const_iterator, value_type const&); template<typename InputIterator> void insert(InputIterator, InputIterator); iterator erase(const_iterator); size_type erase(key_type const&); iterator erase(const_iterator, const_iterator); void quick_erase(const_iterator); void erase_return_void(const_iterator); void clear(); void swap(unordered_multimap&); // observers hasher hash_function() const; key_equal key_eq() const; // lookup iterator find(key_type const&); const_iterator find(key_type const&) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&) const; size_type count(key_type const&) const; std::pair<iterator, iterator> equal_range(key_type const&); std::pair<const_iterator, const_iterator> equal_range(key_type const&) const; // bucket interface size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type) const; size_type bucket(key_type const&) const; local_iterator begin(size_type); const_local_iterator begin(size_type) const; local_iterator end(size_type); const_local_iterator end(size_type) const; const_local_iterator cbegin(size_type) const; const_local_iterator cend(size_type); // hash policy float load_factor() const; float max_load_factor() const; void max_load_factor(float); void rehash(size_type); }; // Equality Comparisons template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&); template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&); // swap template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&, unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&);Description Based on chapter 23 of the working draft of the C++ standard [n2960]. But without the updated rules for allocators. Template Parameters Key Key must be Assignable and CopyConstructible. Mapped Mapped must be CopyConstructible Hash A unary function object type that acts a hash function for a Key. It takes a single argument of type Key and returns a value of type std::size_t. Pred A binary function object that implements an equivalence relation on values of type Key. A binary function object that induces an equivalence relation on values of type Key. It takes two arguments of type Key and returns a value of type bool. Alloc An allocator whose value type is the same as the container's value type. The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other. The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash. <anchor id="boost.unordered_multimaptypes"/><computeroutput>unordered_multimap</computeroutput> public types typedef implementation-defined size_type; An unsigned integral type. size_type can represent any non-negative value of difference_type. typedef implementation-defined difference_type; A signed integral type. Is identical to the difference type of iterator and const_iterator. typedef implementation-defined iterator; A iterator whose value type is value_type. The iterator category is at least a forward iterator. Convertible to const_iterator. typedef implementation-defined const_iterator; A constant iterator whose value type is value_type. The iterator category is at least a forward iterator. typedef implementation-defined local_iterator; An iterator with the same value type, difference type and pointer and reference type as iterator. A local_iterator object can be used to iterate through a single bucket. typedef implementation-defined const_local_iterator; A constant iterator with the same value type, difference type and pointer and reference type as const_iterator. A const_local_iterator object can be used to iterate through a single bucket. <anchor id="boost.unordered_multimapconstruct-copy-destruct"/><computeroutput>unordered_multimap</computeroutput> public construct/copy/destructexplicit unordered_multimap(size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.Postconditions:size() == 0template<typename InputIterator> unordered_multimap(InputIterator f, InputIterator l, size_type n = implementation-defined, hasher const& hf = hasher(), key_equal const& eq = key_equal(), allocator_type const& a = allocator_type());Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.unordered_multimap(unordered_multimap const&);The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.Requires:value_type is copy constructibleunordered_multimap(unordered_multimap &&);The move constructor.Notes:This is emulated on compilers without rvalue references.Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). explicit unordered_multimap(Allocator const& a);Constructs an empty container, using allocator a.unordered_multimap(unordered_multimap const& x, Allocator const& a);Constructs an container, copying x's contained elements, hash function, predicate, maximum load factor, but using allocator a.~unordered_multimap();Notes:The destructor is applied to every element, and all memory is deallocatedunordered_multimap& operator=(unordered_multimap const&);The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_multimap) in order to emulate move semantics. Requires:value_type is copy constructibleunordered_multimap& operator=(unordered_multimap &&);The move assignment operator.Notes: On compilers without rvalue references, there is a single assignment operator with the signature operator=(unordered_multimap) in order to emulate move semantics. Requires: value_type is move constructible. (TODO: This is not actually required in this implementation). allocator_type get_allocator() const;<anchor id="id222-bb"/><computeroutput>unordered_multimap</computeroutput> size and capacitybool empty() const;Returns:size() == 0size_type size() const;Returns:std::distance(begin(), end())size_type max_size() const;Returns:size() of the largest possible container. <anchor id="id226-bb"/><computeroutput>unordered_multimap</computeroutput> iteratorsiterator begin(); const_iterator begin() const;Returns:An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. iterator end(); const_iterator end() const;Returns:An iterator which refers to the past-the-end value for the container. const_iterator cbegin() const;Returns:A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. const_iterator cend() const;Returns:A constant iterator which refers to the past-the-end value for the container. <anchor id="id235-bb"/><computeroutput>unordered_multimap</computeroutput> modifierstemplate<typename... Args> iterator emplace(Args&&... args);Inserts an object, constructed with the arguments args, in the container.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.template<typename... Args> iterator emplace_hint(const_iterator hint, Args&&... args);Inserts an object, constructed with the arguments args, in the container.hint is a suggestion to where the element should be inserted.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics.iterator insert(value_type const& obj);Inserts obj in the container.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator insert(const_iterator hint, value_type const& obj);Inserts obj in the container.hint is a suggestion to where the element should be inserted.Returns:An iterator pointing to the inserted element.Throws:If an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.template<typename InputIterator> void insert(InputIterator first, InputIterator last);Inserts a range of elements into the container.Throws:When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect.Notes:Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.Pointers and references to elements are never invalidated.iterator erase(const_iterator position);Erase the element pointed to by position.Returns:The iterator following position before the erasure.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: When the number of elements is a lot smaller than the number of buckets this function can be very inefficient as it has to search through empty buckets for the next element, in order to return the iterator. The method quick_erase is faster, but has yet to be standardized. size_type erase(key_type const& k);Erase all elements with key equivalent to k.Returns:The number of elements erased.Throws:Only throws an exception if it is thrown by hasher or key_equal.iterator erase(const_iterator first, const_iterator last);Erases the elements in the range from first to last.Returns:The iterator following the erased elements - i.e. last.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.void quick_erase(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is faster than erase as it doesn't have to find the next element in the container - a potentially costly operation. As it hasn't been standardized, it's likely that this may change in the future. void erase_return_void(const_iterator position);Erase the element pointed to by position.Throws:Only throws an exception if it is thrown by hasher or key_equal.In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.Notes: This method is now deprecated, use quick_return instead. Although be warned that as that isn't standardized yet, it could also change. void clear();Erases all elements in the container.Postconditions:size() == 0Throws:Never throws an exception.void swap(unordered_multimap&);Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.<anchor id="id248-bb"/><computeroutput>unordered_multimap</computeroutput> observershasher hash_function() const;Returns:The container's hash function. key_equal key_eq() const;Returns:The container's key equality predicate. <anchor id="id251-bb"/><computeroutput>unordered_multimap</computeroutput> lookupiterator find(key_type const& k); const_iterator find(key_type const& k) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq) const;Returns:An iterator pointing to an element with key equivalent to k, or b.end() if no such element exists.Notes: The templated overloads are a non-standard extensions which allows you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged. size_type count(key_type const& k) const;Returns:The number of elements with key equivalent to k.std::pair<iterator, iterator> equal_range(key_type const& k); std::pair<const_iterator, const_iterator> equal_range(key_type const& k) const;Returns:A range containing all elements with key equivalent to k. If the container doesn't container any such elements, returns std::make_pair(b.end(),b.end()). <anchor id="id261-bb"/><computeroutput>unordered_multimap</computeroutput> bucket interfacesize_type bucket_count() const;Returns:The number of buckets.size_type max_bucket_count() const;Returns:An upper bound on the number of buckets.size_type bucket_size(size_type n) const;Requires:n < bucket_count()Returns:The number of elements in bucket n.size_type bucket(key_type const& k) const;Returns:The index of the bucket which would contain an element with key k.Postconditions:The return value is less than bucket_count()local_iterator begin(size_type n); const_local_iterator begin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the first element in the bucket with index n.local_iterator end(size_type n); const_local_iterator end(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A local iterator pointing the 'one past the end' element in the bucket with index n.const_local_iterator cbegin(size_type n) const;Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the first element in the bucket with index n.const_local_iterator cend(size_type n);Requires:n shall be in the range [0, bucket_count()).Returns:A constant local iterator pointing the 'one past the end' element in the bucket with index n.<anchor id="id274-bb"/><computeroutput>unordered_multimap</computeroutput> hash policyfloat load_factor() const;Returns:The average number of elements per bucket.float max_load_factor() const;Returns:Returns the current maximum load factor.void max_load_factor(float z);Effects:Changes the container's maximum load factor, using z as a hint.void rehash(size_type n);Changes the number of buckets so that there at least n buckets, and so that the load factor is less than the maximum load factor.Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.Throws:The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.<anchor id="id279-bb"/><computeroutput>unordered_multimap</computeroutput> Equality Comparisonstemplate<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator==(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& x, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.template<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> bool operator!=(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& x, unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& y);Notes:This is a boost extension.Behavior is undefined if the two containers don't have equivalent equality predicates.<anchor id="id280-bb"/><computeroutput>unordered_multimap</computeroutput> swaptemplate<typename Key, typename Mapped, typename Hash, typename Pred, typename Alloc> void swap(unordered_multimap<Key, Mapped, Hash, Pred, Alloc>& x, unordered_multimap<Key, Mapped, Hash, Pred, Alloc>& y);Effects:x.swap(y)Throws:If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of Hash or Pred.Notes:For a discussion of the behavior when allocators aren't equal see the implementation details.