forked from boostorg/unordered
Update unordered_multiset refernce to follow new synopsis
This commit is contained in:
@ -198,21 +198,21 @@ template<class Key, class Hash, class Pred, class Alloc>
|
||||
[cols="1,1"]
|
||||
|===
|
||||
|
||||
|_Value_
|
||||
|`Value` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).
|
||||
|_Key_
|
||||
|`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).
|
||||
|
||||
|_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`.
|
||||
|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 `Value`. A binary function object that induces an equivalence relation on values of type `Value`. It takes two arguments of type `Value` and returns a value of type bool.
|
||||
|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_
|
||||
|_Allocator_
|
||||
|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 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.
|
||||
|
||||
@ -315,15 +315,6 @@ See node_handle_set for details.
|
||||
|
||||
---
|
||||
|
||||
[source,c++,subs=+quotes]
|
||||
----
|
||||
typedef _implementation-defined_ insert_return_type;
|
||||
----
|
||||
|
||||
Structure returned by inserting node_type.
|
||||
|
||||
---
|
||||
|
||||
=== Constructors
|
||||
|
||||
==== Default Constructor
|
||||
@ -343,13 +334,13 @@ Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type`
|
||||
==== Bucket Count Constructor
|
||||
```c++
|
||||
explicit unordered_multiset(size_type n,
|
||||
hasher const& hf = hasher(),
|
||||
key_equal const& eq = key_equal(),
|
||||
allocator_type const& a = allocator_type());
|
||||
const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& 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
|
||||
function, `eql` as the key equality predicate, `a` as the allocator and a maximum
|
||||
load factor of `1.0`.
|
||||
|
||||
Postconditions:: `size() == 0`
|
||||
@ -358,9 +349,26 @@ Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type`
|
||||
|
||||
---
|
||||
|
||||
==== Iterator Range Constructor
|
||||
[source,c++,subs="+quotes"]
|
||||
----
|
||||
template<class InputIterator>
|
||||
unordered_multiset(InputIterator f, InputIterator l,
|
||||
size_type n = _implementation-defined_,
|
||||
const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
----
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` 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.
|
||||
|
||||
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
|
||||
|
||||
---
|
||||
|
||||
==== Copy Constructor
|
||||
```c++
|
||||
unordered_multiset(unordered_multiset const& other);
|
||||
unordered_multiset(const unordered_multiset& other);
|
||||
```
|
||||
|
||||
The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.
|
||||
@ -387,7 +395,7 @@ So, for example, you can't return the container from a function.
|
||||
|
||||
==== Allocator Constructor
|
||||
```c++
|
||||
explicit unordered_multiset(Allocator const& a);
|
||||
explicit unordered_multiset(const Allocator& a);
|
||||
```
|
||||
|
||||
Constructs an empty container, using allocator `a`.
|
||||
@ -396,7 +404,7 @@ Constructs an empty container, using allocator `a`.
|
||||
|
||||
==== Copy Constructor with Allocator
|
||||
```c++
|
||||
unordered_multiset(unordered_multiset const& other, Allocator const& a);
|
||||
unordered_multiset(const unordered_multiset& other, const Allocator& a);
|
||||
```
|
||||
|
||||
Constructs an container, copying ``other``'s contained elements, hash function, predicate, maximum load factor, but using allocator `a`.
|
||||
@ -405,7 +413,7 @@ Constructs an container, copying ``other``'s contained elements, hash function,
|
||||
|
||||
==== Move Constructor with Allocator
|
||||
```c++
|
||||
unordered_multiset(unordered_multiset&& other, Allocator const& a);
|
||||
unordered_multiset(unordered_multiset&& other, const Allocator& a);
|
||||
```
|
||||
|
||||
Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`.
|
||||
@ -415,9 +423,25 @@ Requires:: `value_type` is move insertable.
|
||||
|
||||
---
|
||||
|
||||
==== Initializer List Constructor
|
||||
[source,c++,subs="+quotes"]
|
||||
----
|
||||
unordered_multiset(initializer_list<value_type> il,
|
||||
size_type n = _implementation-defined_,
|
||||
const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
----
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it.
|
||||
|
||||
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
|
||||
|
||||
---
|
||||
|
||||
==== Bucket Count Constructor with Allocator
|
||||
```c++
|
||||
unordered_multiset(size_type n, allocator_type const& a);
|
||||
unordered_multiset(size_type n, const allocator_type& a);
|
||||
```
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`.
|
||||
@ -429,7 +453,7 @@ Requires:: `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp
|
||||
|
||||
==== Bucket Count Constructor with Hasher and Allocator
|
||||
```c++
|
||||
unordered_multiset(size_type n, hasher const& hf, allocator_type const& a);
|
||||
unordered_multiset(size_type n, const hasher& hf, const allocator_type& a);
|
||||
```
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`.
|
||||
@ -439,63 +463,25 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D
|
||||
|
||||
---
|
||||
|
||||
==== Initializer List Constructor
|
||||
[source,c++,subs="quotes,macros"]
|
||||
----
|
||||
unordered_multiset(initializer_list++<++value_type++>++ il,
|
||||
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 `il` into it.
|
||||
|
||||
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
|
||||
|
||||
---
|
||||
|
||||
==== Iterator Range Constructor
|
||||
[source,c++,subs="quotes,macros"]
|
||||
----
|
||||
template++<++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.
|
||||
|
||||
Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
|
||||
|
||||
---
|
||||
|
||||
==== Iterator Range Constructor with Bucket Count and Allocator
|
||||
[source,c++,subs="quotes,macros"]
|
||||
[source,c++,subs="+quotes"]
|
||||
----
|
||||
template++<++typename InputIterator++>++
|
||||
unordered_multiset(InputIterator f,
|
||||
InputIterator l,
|
||||
size_type n,
|
||||
allocator_type const& a);
|
||||
template<class InputIterator>
|
||||
unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
|
||||
----
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
|
||||
|
||||
Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
|
||||
|
||||
---
|
||||
|
||||
==== Iterator Range Constructor with Bucket Count and Hasher
|
||||
[source,c++,subs="quotes,macros"]
|
||||
[source,c++,subs="+quotes"]
|
||||
----
|
||||
template++<++typename InputIterator++>++
|
||||
unordered_multiset(InputIterator f,
|
||||
InputIterator l,
|
||||
size_type n,
|
||||
hasher const& hf,
|
||||
allocator_type const& a);
|
||||
template<class InputIterator>
|
||||
unordered_multiset(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
||||
const allocator_type& a);
|
||||
----
|
||||
|
||||
Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.
|
||||
@ -509,6 +495,7 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D
|
||||
```c++
|
||||
~unordered_multiset();
|
||||
```
|
||||
|
||||
Note:: The destructor is applied to every element, and all memory is deallocated
|
||||
|
||||
---
|
||||
@ -518,7 +505,7 @@ Note:: The destructor is applied to every element, and all memory is deallocated
|
||||
==== Copy Assignment
|
||||
|
||||
```c++
|
||||
unordered_multiset& operator=(unordered_multiset const& other);
|
||||
unordered_multiset& operator=(const unordered_multiset& other);
|
||||
```
|
||||
|
||||
The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.
|
||||
@ -531,7 +518,10 @@ Requires:: `value_type` is copy constructible
|
||||
|
||||
==== Move Assignment
|
||||
```c++
|
||||
unordered_multiset& operator=(unordered_multiset&& other);
|
||||
unordered_multiset& operator=(unordered_multiset&& other)
|
||||
noexcept(boost::allocator_traits<Allocator>::is_always_equal::value &&
|
||||
boost::is_nothrow_move_assignable_v<Hash> &&
|
||||
boost::is_nothrow_move_assignable_v<Pred>);
|
||||
```
|
||||
The move assignment operator.
|
||||
|
||||
@ -552,12 +542,53 @@ Assign from values in initializer list. All existing elements are either overwri
|
||||
|
||||
Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^].
|
||||
|
||||
---
|
||||
|
||||
=== Iterators
|
||||
|
||||
==== begin
|
||||
```c++
|
||||
iterator begin() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
==== end
|
||||
```c++
|
||||
iterator end() noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: An iterator which refers to the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
==== cbegin
|
||||
```c++
|
||||
const_iterator cbegin() const noexcept;
|
||||
```
|
||||
Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
==== cend
|
||||
```c++
|
||||
const_iterator cend() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: A `const_iterator` which refers to the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
=== Size and Capacity
|
||||
|
||||
==== empty
|
||||
|
||||
```c++
|
||||
bool empty() const;
|
||||
bool empty() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: `size() == 0`
|
||||
@ -567,7 +598,7 @@ Returns:: `size() == 0`
|
||||
==== size
|
||||
|
||||
```c++
|
||||
size_type size() const;
|
||||
size_type size() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: `std::distance(begin(), end())`
|
||||
@ -577,59 +608,18 @@ Returns:: `std::distance(begin(), end())`
|
||||
==== max_size
|
||||
|
||||
```c++
|
||||
size_type max_size() const;
|
||||
size_type max_size() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: `size()` of the largest possible container.
|
||||
|
||||
---
|
||||
|
||||
=== Iterators
|
||||
|
||||
==== begin
|
||||
```c++
|
||||
iterator 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.
|
||||
|
||||
---
|
||||
|
||||
==== end
|
||||
```c++
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
```
|
||||
|
||||
Returns:: An iterator which refers to the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
==== cbegin
|
||||
```c++
|
||||
const_iterator cbegin() const;
|
||||
```
|
||||
Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
==== cend
|
||||
```c++
|
||||
const_iterator cend() const;
|
||||
```
|
||||
|
||||
Returns:: A `const_iterator` which refers to the past-the-end value for the container.
|
||||
|
||||
---
|
||||
|
||||
=== Modifiers
|
||||
|
||||
==== emplace
|
||||
```c++
|
||||
template<typename... Args>
|
||||
iterator
|
||||
emplace(Args&&... args);
|
||||
template<class... Args> iterator emplace(Args&&... args);
|
||||
```
|
||||
|
||||
Inserts an object, constructed with the arguments args, in the container.
|
||||
@ -649,9 +639,7 @@ Since existing `std::pair` implementations don't support `std::piecewise_constru
|
||||
|
||||
==== emplace_hint
|
||||
```c++
|
||||
template<typename... Args>
|
||||
iterator
|
||||
emplace_hint(const_iterator hint, Args&&... args);
|
||||
template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
```
|
||||
|
||||
Inserts an object, constructed with the arguments args, in the container.
|
||||
@ -674,8 +662,7 @@ Since existing `std::pair` implementations don't support `std::piecewise_constru
|
||||
|
||||
==== Copy Insert
|
||||
```c++
|
||||
iterator
|
||||
insert(value_type const& obj);
|
||||
iterator insert(const value_type& obj);
|
||||
```
|
||||
|
||||
Inserts `obj` in the container.
|
||||
@ -692,8 +679,7 @@ Notes:: Can invalidate iterators, but only if the insert causes the load factor
|
||||
|
||||
==== Move Insert
|
||||
```c++
|
||||
iterator
|
||||
insert(value_type&& obj);
|
||||
iterator insert(value_type&& obj);
|
||||
```
|
||||
|
||||
Inserts `obj` in the container.
|
||||
@ -708,29 +694,9 @@ Notes:: Can invalidate iterators, but only if the insert causes the load factor
|
||||
|
||||
---
|
||||
|
||||
==== Insert with `node_handle`
|
||||
```c++
|
||||
iterator
|
||||
insert(node_type&& nh);
|
||||
```
|
||||
|
||||
If `nh` is empty, has no effect.
|
||||
|
||||
Otherwise inserts the element owned by `nh`.
|
||||
|
||||
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
|
||||
|
||||
Returns:: If `nh` was empty, returns `end()`. Otherwise returns an iterator pointing to the newly 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. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet.
|
||||
|
||||
---
|
||||
|
||||
==== Copy Insert with Hint
|
||||
```c++
|
||||
iterator insert(const_iterator hint, value_type const& obj);
|
||||
iterator insert(const_iterator hint, const value_type& obj);
|
||||
```
|
||||
|
||||
Inserts `obj` in the container.
|
||||
@ -766,33 +732,9 @@ Notes:: The standard is fairly vague on the meaning of the hint. But the only pr
|
||||
|
||||
---
|
||||
|
||||
==== Insert with Hint and `node_handle`
|
||||
```c++
|
||||
iterator insert(const_iterator hint, node_type&& nh);
|
||||
```
|
||||
|
||||
If `nh` is empty, has no effect.
|
||||
|
||||
Otherwise inserts the element owned by `nh`.
|
||||
|
||||
`hint` is a suggestion to where the element should be inserted.
|
||||
|
||||
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
|
||||
|
||||
Returns:: If `nh` was empty, returns `end()`.
|
||||
|
||||
Otherwise returns an iterator pointing to the newly 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. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet.
|
||||
|
||||
---
|
||||
|
||||
==== Insert Iterator Range
|
||||
```c++
|
||||
template<typename InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
template<class InputIterator> void insert(InputIterator first, InputIterator last);
|
||||
```
|
||||
|
||||
Inserts a range of elements into the container.
|
||||
@ -833,16 +775,13 @@ Notes:: In C++17 a node extracted using this method can be inserted into a compa
|
||||
|
||||
---
|
||||
|
||||
==== Transparent Extract by Value
|
||||
==== Extract by Value
|
||||
```c++
|
||||
template<typename K>
|
||||
node_type extract(K&& k);
|
||||
node_type extract(const key_type& k);
|
||||
```
|
||||
|
||||
Removes an element with key equivalent to `k`.
|
||||
|
||||
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
|
||||
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
|
||||
|
||||
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
|
||||
@ -851,22 +790,69 @@ Notes:: In C++17 a node extracted using this method can be inserted into a compa
|
||||
|
||||
---
|
||||
|
||||
==== Extract by Value
|
||||
==== Transparent Extract by Value
|
||||
```c++
|
||||
node_type extract(key_type const& k);
|
||||
template<class K> node_type extract(K&& k);
|
||||
```
|
||||
|
||||
Removes an element with key equivalent to `k`.
|
||||
|
||||
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`.
|
||||
|
||||
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
|
||||
|
||||
Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet.
|
||||
|
||||
---
|
||||
|
||||
==== Insert with `node_handle`
|
||||
```c++
|
||||
iterator insert(node_type&& nh);
|
||||
```
|
||||
|
||||
If `nh` is empty, has no effect.
|
||||
|
||||
Otherwise inserts the element owned by `nh`.
|
||||
|
||||
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
|
||||
|
||||
Returns:: If `nh` was empty, returns `end()`. Otherwise returns an iterator pointing to the newly 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. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet.
|
||||
|
||||
---
|
||||
|
||||
==== Insert with Hint and `node_handle`
|
||||
```c++
|
||||
iterator insert(const_iterator hint, node_type&& nh);
|
||||
```
|
||||
|
||||
If `nh` is empty, has no effect.
|
||||
|
||||
Otherwise inserts the element owned by `nh`.
|
||||
|
||||
`hint` is a suggestion to where the element should be inserted.
|
||||
|
||||
Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator.
|
||||
|
||||
Returns:: If `nh` was empty, returns `end()`.
|
||||
|
||||
Otherwise returns an iterator pointing to the newly 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. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet.
|
||||
|
||||
---
|
||||
|
||||
==== Erase by Position
|
||||
|
||||
```c++
|
||||
iterator erase(iterator position);
|
||||
iterator erase(const_iterator position);
|
||||
```
|
||||
|
||||
@ -880,6 +866,34 @@ Notes:: In older versions this could be inefficient because it had to search thr
|
||||
|
||||
---
|
||||
|
||||
==== Erase by Value
|
||||
```c++
|
||||
size_type erase(const key_type& 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`.
|
||||
|
||||
---
|
||||
|
||||
==== Transparent Erase by Value
|
||||
```c++
|
||||
template<class K> size_type erase(K&& x);
|
||||
```
|
||||
|
||||
Erase all elements with key equivalent to `k`.
|
||||
|
||||
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
Returns:: The number of elements erased.
|
||||
|
||||
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
|
||||
|
||||
---
|
||||
|
||||
==== Erase Range
|
||||
|
||||
```c++
|
||||
@ -894,35 +908,6 @@ Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In
|
||||
|
||||
---
|
||||
|
||||
==== Transparent Erase by Value
|
||||
```c++
|
||||
template<typename K>
|
||||
size_type erase(K&& k);
|
||||
```
|
||||
|
||||
Erase all elements with key equivalent to `k`.
|
||||
|
||||
This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
|
||||
Returns:: The number of elements erased.
|
||||
|
||||
Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`.
|
||||
|
||||
---
|
||||
|
||||
==== Erase by Value
|
||||
```c++
|
||||
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`.
|
||||
|
||||
---
|
||||
|
||||
==== quick_erase
|
||||
```c++
|
||||
void quick_erase(const_iterator position);
|
||||
@ -949,22 +934,12 @@ Notes:: This method was implemented because returning an iterator to the next el
|
||||
|
||||
---
|
||||
|
||||
==== clear
|
||||
```c++
|
||||
void clear();
|
||||
```
|
||||
|
||||
Erases all elements in the container.
|
||||
|
||||
Postconditions:: `size() == 0`
|
||||
|
||||
Throws:: Never throws an exception.
|
||||
|
||||
---
|
||||
|
||||
==== swap
|
||||
```c++
|
||||
void swap(unordered_multiset& other);
|
||||
void swap(unordered_multiset&)
|
||||
noexcept(boost::allocator_traits<Allocator>::is_always_equal::value &&
|
||||
boost::is_nothrow_swappable_v<Hash> &&
|
||||
boost::is_nothrow_swappable_v<Pred>);
|
||||
```
|
||||
|
||||
Swaps the contents of the container with the parameter.
|
||||
@ -977,10 +952,23 @@ Notes:: The exception specifications aren't quite the same as the C++11 standard
|
||||
|
||||
---
|
||||
|
||||
==== clear
|
||||
```c++
|
||||
void clear() noexcept;
|
||||
```
|
||||
|
||||
Erases all elements in the container.
|
||||
|
||||
Postconditions:: `size() == 0`
|
||||
|
||||
Throws:: Never throws an exception.
|
||||
|
||||
---
|
||||
|
||||
==== merge
|
||||
```c++
|
||||
template<typename H2, typename P2>
|
||||
void merge(unordered_multiset<Value, Mapped, H2, P2, Alloc>& source);
|
||||
template<class H2, class P2>
|
||||
void merge(unordered_multiset<Key, H2, P2, Allocator>& source);
|
||||
```
|
||||
|
||||
Notes:: Does not support merging with a compatible `unordered_set` yet.
|
||||
@ -989,8 +977,8 @@ Notes:: Does not support merging with a compatible `unordered_set` yet.
|
||||
|
||||
==== merge (rvalue reference)
|
||||
```c++
|
||||
template<typename H2, typename P2>
|
||||
void merge(unordered_multiset<Value, Mapped, H2, P2, Alloc>&& source);
|
||||
template<class H2, class P2>
|
||||
void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);
|
||||
```
|
||||
|
||||
Notes:: Does not support merging with a compatible `unordered_set` yet.
|
||||
@ -1001,9 +989,11 @@ Notes:: Does not support merging with a compatible `unordered_set` yet.
|
||||
|
||||
==== get_allocator
|
||||
```
|
||||
allocator_type get_allocator() const;
|
||||
allocator_type get_allocator() const noexcept;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
==== hash_function
|
||||
```
|
||||
hasher hash_function() const;
|
||||
@ -1013,6 +1003,8 @@ Returns:: The container's hash function.
|
||||
|
||||
---
|
||||
|
||||
==== key_eq
|
||||
|
||||
```
|
||||
key_equal key_eq() const;
|
||||
```
|
||||
@ -1025,90 +1017,66 @@ Returns:: The container's key equality predicate
|
||||
|
||||
==== find
|
||||
```c++
|
||||
iterator find(key_type const& k);
|
||||
const_iterator find(key_type const& k) const;
|
||||
|
||||
template<typename K>
|
||||
iterator
|
||||
find(K const& k);
|
||||
|
||||
template<typename K>
|
||||
const_iterator
|
||||
find(K const& k) const;
|
||||
|
||||
template<
|
||||
typename CompatibleValue,
|
||||
typename CompatibleHash,
|
||||
typename CompatiblePredicate>
|
||||
iterator
|
||||
find(CompatibleValue const& k,
|
||||
CompatibleHash const& hash,
|
||||
CompatiblePredicate const& eq);
|
||||
|
||||
template<
|
||||
typename CompatibleValue,
|
||||
typename CompatibleHash,
|
||||
typename CompatiblePredicate>
|
||||
const_iterator
|
||||
find(CompatibleValue const& k,
|
||||
CompatibleHash const& hash,
|
||||
CompatiblePredicate const& eq) const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
template<class K>
|
||||
iterator find(const K& k);
|
||||
template<class K>
|
||||
const_iterator find(const K& k) 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;
|
||||
```
|
||||
|
||||
Returns:: An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists.
|
||||
|
||||
Notes:: The templated overloads containing `CompatibleValue`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow 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 and instead the `K` member function templates should be used. +
|
||||
The `template <typename K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
|
||||
---
|
||||
|
||||
==== contains
|
||||
```c++
|
||||
template<typename K>
|
||||
bool contains(K const& key);
|
||||
bool contains(key_type const& key) const;
|
||||
```
|
||||
|
||||
Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container
|
||||
|
||||
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
Notes:: The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow 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 and instead the `K` member function templates should be used. +
|
||||
The `template <typename K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
---
|
||||
|
||||
==== count
|
||||
```c++
|
||||
template<typename K>
|
||||
size_type count(K const& k) const;
|
||||
size_type count(key_type const& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
template<class K>
|
||||
size_type count(const K& k) const;
|
||||
```
|
||||
|
||||
Returns:: The number of elements with key equivalent to `k`.
|
||||
|
||||
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
---
|
||||
|
||||
==== contains
|
||||
```c++
|
||||
bool contains(const key_type& k) const;
|
||||
template<class K>
|
||||
bool contains(const K& k) const;
|
||||
```
|
||||
|
||||
Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container
|
||||
|
||||
Notes:: The `template <typename K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
---
|
||||
|
||||
==== equal_range
|
||||
```c++
|
||||
std::pair<iterator, iterator>
|
||||
equal_range(key_type const& k);
|
||||
|
||||
std::pair<const_iterator, const_iterator>
|
||||
equal_range(key_type const& k) const;
|
||||
|
||||
template<typename K>
|
||||
std::pair<iterator, iterator>
|
||||
equal_range(K const& k);
|
||||
|
||||
template<typename K>
|
||||
std::pair<const_iterator, const_iterator>
|
||||
equal_range(K const& k) const;
|
||||
std::pair<iterator, iterator> equal_range(const key_type& k);
|
||||
std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
template<class K>
|
||||
std::pair<iterator, iterator> equal_range(const K& k);
|
||||
template<class K>
|
||||
std::pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
||||
```
|
||||
|
||||
Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`.
|
||||
|
||||
Notes:: The `template <typename K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type.
|
||||
Notes:: The `template <typename K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
|
||||
|
||||
---
|
||||
|
||||
@ -1116,7 +1084,7 @@ Notes:: The `template <typename K>` overloads only participate in overload resol
|
||||
|
||||
==== bucket_count
|
||||
```c++
|
||||
size_type bucket_count() const;
|
||||
size_type bucket_count() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: The number of buckets.
|
||||
@ -1125,7 +1093,7 @@ Returns:: The number of buckets.
|
||||
|
||||
==== max_bucket_count
|
||||
```c++
|
||||
size_type max_bucket_count() const;
|
||||
size_type max_bucket_count() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: An upper bound on the number of buckets.
|
||||
@ -1145,7 +1113,7 @@ Returns:: The number of elements in bucket `n`.
|
||||
|
||||
==== bucket
|
||||
```c++
|
||||
size_type bucket(key_type const& k) const;
|
||||
size_type bucket(const key_type& k) const;
|
||||
```
|
||||
|
||||
Returns:: The index of the bucket which would contain an element with key `k`.
|
||||
@ -1205,7 +1173,7 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t
|
||||
|
||||
==== load_factor
|
||||
```c++
|
||||
float load_factor() const;
|
||||
float load_factor() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: The average number of elements per bucket.
|
||||
@ -1215,7 +1183,7 @@ Returns:: The average number of elements per bucket.
|
||||
==== max_load_factor
|
||||
|
||||
```c++
|
||||
float max_load_factor() const;
|
||||
float max_load_factor() const noexcept;
|
||||
```
|
||||
|
||||
Returns:: Returns the current maximum load factor.
|
||||
@ -1231,7 +1199,6 @@ Effects:: Changes the container's maximum load factor, using `z` as a hint.
|
||||
|
||||
---
|
||||
|
||||
|
||||
==== rehash
|
||||
```c++
|
||||
void rehash(size_type n);
|
||||
@ -1254,18 +1221,15 @@ Invalidates iterators, and changes the order of elements. Pointers and reference
|
||||
|
||||
Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.
|
||||
|
||||
---
|
||||
|
||||
=== Equality Comparisons
|
||||
|
||||
==== operator==
|
||||
```c++
|
||||
template<
|
||||
typename Value,
|
||||
typename Mapped,
|
||||
typename Hash,
|
||||
typename Pred,
|
||||
typename Alloc>
|
||||
bool operator==(unordered_multiset<Value, Mapped, Hash, Pred, Alloc> const& x,
|
||||
unordered_multiset<Value, Mapped, Hash, Pred, Alloc> const& y);
|
||||
template<class Key, class Hash, class Pred, class Alloc>
|
||||
bool operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
||||
const unordered_multiset<Key, Hash, Pred, Alloc>& y);
|
||||
```
|
||||
|
||||
Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
|
||||
@ -1276,26 +1240,23 @@ Notes:: The behavior of this function was changed to match the C++11 standard in
|
||||
|
||||
==== operator!=
|
||||
```c++
|
||||
template<
|
||||
typename Value,
|
||||
typename Mapped,
|
||||
typename Hash,
|
||||
typename Pred,
|
||||
typename Alloc>
|
||||
bool operator!=(unordered_multiset<Value, Mapped, Hash, Pred, Alloc> const& x,
|
||||
unordered_multiset<Value, Mapped, Hash, Pred, Alloc> const& y);
|
||||
template<class Key, class Hash, class Pred, class Alloc>
|
||||
bool operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
||||
const unordered_multiset<Key, Hash, Pred, Alloc>& y);
|
||||
```
|
||||
|
||||
Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
|
||||
|
||||
Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates.
|
||||
|
||||
---
|
||||
|
||||
=== Swap
|
||||
```c++
|
||||
template<typename Value, typename Mapped, typename Hash, typename Pred,
|
||||
typename Alloc>
|
||||
void swap(unordered_multiset<Value, Mapped, Hash, Pred, Alloc>& x,
|
||||
unordered_multiset<Value, Mapped, Hash, Pred, Alloc>& y);
|
||||
template<class Key, class Hash, class Pred, class Alloc>
|
||||
void swap(unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
||||
unordered_multiset<Key, Hash, Pred, Alloc>& y)
|
||||
noexcept(noexcept(x.swap(y)));
|
||||
```
|
||||
|
||||
Swaps the contents of `x` and `y`.
|
||||
|
Reference in New Issue
Block a user