- tmp/tmp8ettopg0/{from.md → to.md} +141 -114
tmp/tmp8ettopg0/{from.md → to.md}
RENAMED
|
@@ -7,11 +7,11 @@ unique keys (an `unordered_set` contains at most one of each key value)
|
|
| 7 |
and in which the elements’ keys are the elements themselves. The
|
| 8 |
`unordered_set` class supports forward iterators.
|
| 9 |
|
| 10 |
An `unordered_set` meets all of the requirements of a container
|
| 11 |
[[container.reqmts]], of an allocator-aware container
|
| 12 |
-
[[container.alloc.reqmts]], of an unordered associative container
|
| 13 |
[[unord.req]]. It provides the operations described in the preceding
|
| 14 |
requirements table for unique keys; that is, an `unordered_set` supports
|
| 15 |
the `a_uniq` operations in that table, not the `a_eq` operations. For an
|
| 16 |
`unordered_set<Key>` the `key_type` and the `value_type` are both `Key`.
|
| 17 |
The `iterator` and `const_iterator` types are both constant iterator
|
|
@@ -19,10 +19,13 @@ types. It is unspecified whether they are the same type.
|
|
| 19 |
|
| 20 |
Subclause [[unord.set]] only describes operations on `unordered_set`
|
| 21 |
that are not described in one of the requirement tables, or for which
|
| 22 |
there is additional semantic information.
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
``` cpp
|
| 25 |
namespace std {
|
| 26 |
template<class Key,
|
| 27 |
class Hash = hash<Key>,
|
| 28 |
class Pred = equal_to<Key>,
|
|
@@ -33,12 +36,12 @@ namespace std {
|
|
| 33 |
using key_type = Key;
|
| 34 |
using value_type = Key;
|
| 35 |
using hasher = Hash;
|
| 36 |
using key_equal = Pred;
|
| 37 |
using allocator_type = Allocator;
|
| 38 |
-
using pointer =
|
| 39 |
-
using const_pointer =
|
| 40 |
using reference = value_type&;
|
| 41 |
using const_reference = const value_type&;
|
| 42 |
using size_type = implementation-defined // type of unordered_set::size_type; // see [container.requirements]
|
| 43 |
using difference_type = implementation-defined // type of unordered_set::difference_type; // see [container.requirements]
|
| 44 |
|
|
@@ -48,162 +51,163 @@ namespace std {
|
|
| 48 |
using const_local_iterator = implementation-defined // type of unordered_set::const_local_iterator; // see [container.requirements]
|
| 49 |
using node_type = unspecified;
|
| 50 |
using insert_return_type = insert-return-type<iterator, node_type>;
|
| 51 |
|
| 52 |
// [unord.set.cnstr], construct/copy/destroy
|
| 53 |
-
unordered_set();
|
| 54 |
-
explicit unordered_set(size_type n,
|
| 55 |
-
const hasher& hf = hasher(),
|
| 56 |
const key_equal& eql = key_equal(),
|
| 57 |
const allocator_type& a = allocator_type());
|
| 58 |
template<class InputIterator>
|
| 59 |
-
unordered_set(InputIterator f, InputIterator l,
|
| 60 |
-
|
| 61 |
-
const hasher& hf = hasher(),
|
| 62 |
const key_equal& eql = key_equal(),
|
| 63 |
const allocator_type& a = allocator_type());
|
| 64 |
template<container-compatible-range<value_type> R>
|
| 65 |
-
unordered_set(from_range_t, R&& rg,
|
| 66 |
-
|
| 67 |
-
const hasher& hf = hasher(),
|
| 68 |
const key_equal& eql = key_equal(),
|
| 69 |
const allocator_type& a = allocator_type());
|
| 70 |
-
unordered_set(const unordered_set&);
|
| 71 |
-
unordered_set(unordered_set&&);
|
| 72 |
-
explicit unordered_set(const Allocator&);
|
| 73 |
-
unordered_set(const unordered_set&, const type_identity_t<Allocator>&);
|
| 74 |
-
unordered_set(unordered_set&&, const type_identity_t<Allocator>&);
|
| 75 |
-
unordered_set(initializer_list<value_type> il,
|
| 76 |
-
|
| 77 |
-
const hasher& hf = hasher(),
|
| 78 |
const key_equal& eql = key_equal(),
|
| 79 |
const allocator_type& a = allocator_type());
|
| 80 |
-
unordered_set(size_type n, const allocator_type& a)
|
| 81 |
: unordered_set(n, hasher(), key_equal(), a) { }
|
| 82 |
-
unordered_set(size_type n, const hasher& hf, const allocator_type& a)
|
| 83 |
: unordered_set(n, hf, key_equal(), a) { }
|
| 84 |
template<class InputIterator>
|
| 85 |
-
unordered_set(InputIterator f, InputIterator l, size_type n,
|
|
|
|
| 86 |
: unordered_set(f, l, n, hasher(), key_equal(), a) { }
|
| 87 |
template<class InputIterator>
|
| 88 |
-
unordered_set(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 89 |
const allocator_type& a)
|
| 90 |
: unordered_set(f, l, n, hf, key_equal(), a) { }
|
| 91 |
-
unordered_set(initializer_list<value_type> il, size_type n,
|
|
|
|
| 92 |
: unordered_set(il, n, hasher(), key_equal(), a) { }
|
| 93 |
template<container-compatible-range<value_type> R>
|
| 94 |
-
unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
|
| 95 |
: unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { }
|
| 96 |
template<container-compatible-range<value_type> R>
|
| 97 |
-
unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf,
|
|
|
|
| 98 |
: unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }
|
| 99 |
-
unordered_set(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 100 |
const allocator_type& a)
|
| 101 |
: unordered_set(il, n, hf, key_equal(), a) { }
|
| 102 |
-
~unordered_set();
|
| 103 |
-
unordered_set& operator=(const unordered_set&);
|
| 104 |
-
unordered_set& operator=(unordered_set&&)
|
| 105 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 106 |
-
is_nothrow_move_assignable_v<Hash> &&
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
allocator_type get_allocator() const noexcept;
|
| 110 |
|
| 111 |
// iterators
|
| 112 |
-
iterator begin() noexcept;
|
| 113 |
-
const_iterator begin() const noexcept;
|
| 114 |
-
iterator end() noexcept;
|
| 115 |
-
const_iterator end() const noexcept;
|
| 116 |
-
const_iterator cbegin() const noexcept;
|
| 117 |
-
const_iterator cend() const noexcept;
|
| 118 |
|
| 119 |
// capacity
|
| 120 |
-
|
| 121 |
-
size_type size() const noexcept;
|
| 122 |
-
size_type max_size() const noexcept;
|
| 123 |
|
| 124 |
-
// modifiers
|
| 125 |
-
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 126 |
-
template<class... Args>
|
| 127 |
-
|
| 128 |
-
pair<iterator, bool> insert(value_type&
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
template<container-compatible-range<value_type> R>
|
| 133 |
-
void insert_range(R&& rg);
|
| 134 |
-
void insert(initializer_list<value_type>);
|
| 135 |
|
| 136 |
-
node_type extract(const_iterator position);
|
| 137 |
-
node_type extract(const key_type& x);
|
| 138 |
-
template<class K> node_type extract(K&& x);
|
| 139 |
-
insert_return_type insert(node_type&& nh);
|
| 140 |
-
iterator insert(const_iterator hint, node_type&& nh);
|
| 141 |
|
| 142 |
-
iterator erase(iterator position)
|
| 143 |
requires (!same_as<iterator, const_iterator>);
|
| 144 |
-
iterator erase(const_iterator position);
|
| 145 |
-
size_type erase(const key_type& k);
|
| 146 |
-
template<class K> size_type erase(K&& x);
|
| 147 |
-
iterator erase(const_iterator first, const_iterator last);
|
| 148 |
-
void swap(unordered_set&)
|
| 149 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 150 |
-
is_nothrow_swappable_v<Hash> &&
|
| 151 |
-
|
| 152 |
-
void clear() noexcept;
|
| 153 |
|
| 154 |
template<class H2, class P2>
|
| 155 |
-
void merge(unordered_set<Key, H2, P2, Allocator>& source);
|
| 156 |
template<class H2, class P2>
|
| 157 |
-
void merge(unordered_set<Key, H2, P2, Allocator>&& source);
|
| 158 |
template<class H2, class P2>
|
| 159 |
-
void merge(unordered_multiset<Key, H2, P2, Allocator>& source);
|
| 160 |
template<class H2, class P2>
|
| 161 |
-
void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);
|
| 162 |
|
| 163 |
// observers
|
| 164 |
-
hasher hash_function() const;
|
| 165 |
-
key_equal key_eq() const;
|
| 166 |
|
| 167 |
// set operations
|
| 168 |
-
iterator find(const key_type& k);
|
| 169 |
-
const_iterator find(const key_type& k) const;
|
| 170 |
template<class K>
|
| 171 |
-
iterator find(const K& k);
|
| 172 |
template<class K>
|
| 173 |
-
const_iterator find(const K& k) const;
|
| 174 |
-
size_type count(const key_type& k) const;
|
| 175 |
template<class K>
|
| 176 |
-
size_type count(const K& k) const;
|
| 177 |
-
bool contains(const key_type& k) const;
|
| 178 |
template<class K>
|
| 179 |
-
bool contains(const K& k) const;
|
| 180 |
-
pair<iterator, iterator> equal_range(const key_type& k);
|
| 181 |
-
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
| 182 |
template<class K>
|
| 183 |
-
pair<iterator, iterator> equal_range(const K& k);
|
| 184 |
template<class K>
|
| 185 |
-
pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
| 186 |
|
| 187 |
// bucket interface
|
| 188 |
-
size_type bucket_count() const noexcept;
|
| 189 |
-
size_type max_bucket_count() const noexcept;
|
| 190 |
-
size_type bucket_size(size_type n) const;
|
| 191 |
-
size_type bucket(const key_type& k) const;
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
const_local_iterator
|
| 197 |
-
const_local_iterator
|
|
|
|
| 198 |
|
| 199 |
// hash policy
|
| 200 |
-
float load_factor() const noexcept;
|
| 201 |
-
float max_load_factor() const noexcept;
|
| 202 |
-
void max_load_factor(float z);
|
| 203 |
-
void rehash(size_type n);
|
| 204 |
-
void reserve(size_type n);
|
| 205 |
};
|
| 206 |
|
| 207 |
template<class InputIterator,
|
| 208 |
class Hash = hash<iter-value-type<InputIterator>>,
|
| 209 |
class Pred = equal_to<iter-value-type<InputIterator>>,
|
|
@@ -271,13 +275,12 @@ refers to the `size_type` member type of the type deduced by the
|
|
| 271 |
deduction guide.
|
| 272 |
|
| 273 |
#### Constructors <a id="unord.set.cnstr">[[unord.set.cnstr]]</a>
|
| 274 |
|
| 275 |
``` cpp
|
| 276 |
-
unordered_set() : unordered_set(size_type(see below)) { }
|
| 277 |
-
explicit unordered_set(size_type n,
|
| 278 |
-
const hasher& hf = hasher(),
|
| 279 |
const key_equal& eql = key_equal(),
|
| 280 |
const allocator_type& a = allocator_type());
|
| 281 |
```
|
| 282 |
|
| 283 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
|
@@ -287,24 +290,21 @@ buckets. For the default constructor, the number of buckets is
|
|
| 287 |
|
| 288 |
*Complexity:* Constant.
|
| 289 |
|
| 290 |
``` cpp
|
| 291 |
template<class InputIterator>
|
| 292 |
-
unordered_set(InputIterator f, InputIterator l,
|
| 293 |
-
|
| 294 |
-
const hasher& hf = hasher(),
|
| 295 |
const key_equal& eql = key_equal(),
|
| 296 |
const allocator_type& a = allocator_type());
|
| 297 |
template<container-compatible-range<value_type> R>
|
| 298 |
-
unordered_multiset(from_range_t, R&& rg,
|
| 299 |
-
|
| 300 |
-
const hasher& hf = hasher(),
|
| 301 |
const key_equal& eql = key_equal(),
|
| 302 |
const allocator_type& a = allocator_type());
|
| 303 |
-
unordered_set(initializer_list<value_type> il,
|
| 304 |
-
|
| 305 |
-
const hasher& hf = hasher(),
|
| 306 |
const key_equal& eql = key_equal(),
|
| 307 |
const allocator_type& a = allocator_type());
|
| 308 |
```
|
| 309 |
|
| 310 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
|
@@ -317,11 +317,11 @@ buckets. If `n` is not provided, the number of buckets is
|
|
| 317 |
|
| 318 |
#### Erasure <a id="unord.set.erasure">[[unord.set.erasure]]</a>
|
| 319 |
|
| 320 |
``` cpp
|
| 321 |
template<class K, class H, class P, class A, class Predicate>
|
| 322 |
-
typename unordered_set<K, H, P, A>::size_type
|
| 323 |
erase_if(unordered_set<K, H, P, A>& c, Predicate pred);
|
| 324 |
```
|
| 325 |
|
| 326 |
*Effects:* Equivalent to:
|
| 327 |
|
|
@@ -335,5 +335,32 @@ for (auto i = c.begin(), last = c.end(); i != last; ) {
|
|
| 335 |
}
|
| 336 |
}
|
| 337 |
return original_size - c.size();
|
| 338 |
```
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
and in which the elements’ keys are the elements themselves. The
|
| 8 |
`unordered_set` class supports forward iterators.
|
| 9 |
|
| 10 |
An `unordered_set` meets all of the requirements of a container
|
| 11 |
[[container.reqmts]], of an allocator-aware container
|
| 12 |
+
[[container.alloc.reqmts]], and of an unordered associative container
|
| 13 |
[[unord.req]]. It provides the operations described in the preceding
|
| 14 |
requirements table for unique keys; that is, an `unordered_set` supports
|
| 15 |
the `a_uniq` operations in that table, not the `a_eq` operations. For an
|
| 16 |
`unordered_set<Key>` the `key_type` and the `value_type` are both `Key`.
|
| 17 |
The `iterator` and `const_iterator` types are both constant iterator
|
|
|
|
| 19 |
|
| 20 |
Subclause [[unord.set]] only describes operations on `unordered_set`
|
| 21 |
that are not described in one of the requirement tables, or for which
|
| 22 |
there is additional semantic information.
|
| 23 |
|
| 24 |
+
The types `iterator` and `const_iterator` meet the constexpr iterator
|
| 25 |
+
requirements [[iterator.requirements.general]].
|
| 26 |
+
|
| 27 |
``` cpp
|
| 28 |
namespace std {
|
| 29 |
template<class Key,
|
| 30 |
class Hash = hash<Key>,
|
| 31 |
class Pred = equal_to<Key>,
|
|
|
|
| 36 |
using key_type = Key;
|
| 37 |
using value_type = Key;
|
| 38 |
using hasher = Hash;
|
| 39 |
using key_equal = Pred;
|
| 40 |
using allocator_type = Allocator;
|
| 41 |
+
using pointer = allocator_traits<Allocator>::pointer;
|
| 42 |
+
using const_pointer = allocator_traits<Allocator>::const_pointer;
|
| 43 |
using reference = value_type&;
|
| 44 |
using const_reference = const value_type&;
|
| 45 |
using size_type = implementation-defined // type of unordered_set::size_type; // see [container.requirements]
|
| 46 |
using difference_type = implementation-defined // type of unordered_set::difference_type; // see [container.requirements]
|
| 47 |
|
|
|
|
| 51 |
using const_local_iterator = implementation-defined // type of unordered_set::const_local_iterator; // see [container.requirements]
|
| 52 |
using node_type = unspecified;
|
| 53 |
using insert_return_type = insert-return-type<iterator, node_type>;
|
| 54 |
|
| 55 |
// [unord.set.cnstr], construct/copy/destroy
|
| 56 |
+
constexpr unordered_set();
|
| 57 |
+
constexpr explicit unordered_set(size_type n, const hasher& hf = hasher(),
|
|
|
|
| 58 |
const key_equal& eql = key_equal(),
|
| 59 |
const allocator_type& a = allocator_type());
|
| 60 |
template<class InputIterator>
|
| 61 |
+
constexpr unordered_set(InputIterator f, InputIterator l,
|
| 62 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 63 |
const key_equal& eql = key_equal(),
|
| 64 |
const allocator_type& a = allocator_type());
|
| 65 |
template<container-compatible-range<value_type> R>
|
| 66 |
+
constexpr unordered_set(from_range_t, R&& rg,
|
| 67 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 68 |
const key_equal& eql = key_equal(),
|
| 69 |
const allocator_type& a = allocator_type());
|
| 70 |
+
constexpr unordered_set(const unordered_set&);
|
| 71 |
+
constexpr unordered_set(unordered_set&&);
|
| 72 |
+
constexpr explicit unordered_set(const Allocator&);
|
| 73 |
+
constexpr unordered_set(const unordered_set&, const type_identity_t<Allocator>&);
|
| 74 |
+
constexpr unordered_set(unordered_set&&, const type_identity_t<Allocator>&);
|
| 75 |
+
constexpr unordered_set(initializer_list<value_type> il,
|
| 76 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 77 |
const key_equal& eql = key_equal(),
|
| 78 |
const allocator_type& a = allocator_type());
|
| 79 |
+
constexpr unordered_set(size_type n, const allocator_type& a)
|
| 80 |
: unordered_set(n, hasher(), key_equal(), a) { }
|
| 81 |
+
constexpr unordered_set(size_type n, const hasher& hf, const allocator_type& a)
|
| 82 |
: unordered_set(n, hf, key_equal(), a) { }
|
| 83 |
template<class InputIterator>
|
| 84 |
+
constexpr unordered_set(InputIterator f, InputIterator l, size_type n,
|
| 85 |
+
const allocator_type& a)
|
| 86 |
: unordered_set(f, l, n, hasher(), key_equal(), a) { }
|
| 87 |
template<class InputIterator>
|
| 88 |
+
constexpr unordered_set(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 89 |
const allocator_type& a)
|
| 90 |
: unordered_set(f, l, n, hf, key_equal(), a) { }
|
| 91 |
+
constexpr unordered_set(initializer_list<value_type> il, size_type n,
|
| 92 |
+
const allocator_type& a)
|
| 93 |
: unordered_set(il, n, hasher(), key_equal(), a) { }
|
| 94 |
template<container-compatible-range<value_type> R>
|
| 95 |
+
constexpr unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
|
| 96 |
: unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { }
|
| 97 |
template<container-compatible-range<value_type> R>
|
| 98 |
+
constexpr unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf,
|
| 99 |
+
const allocator_type& a)
|
| 100 |
: unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }
|
| 101 |
+
constexpr unordered_set(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 102 |
const allocator_type& a)
|
| 103 |
: unordered_set(il, n, hf, key_equal(), a) { }
|
| 104 |
+
constexpr ~unordered_set();
|
| 105 |
+
constexpr unordered_set& operator=(const unordered_set&);
|
| 106 |
+
constexpr unordered_set& operator=(unordered_set&&)
|
| 107 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 108 |
+
is_nothrow_move_assignable_v<Hash> && is_nothrow_move_assignable_v<Pred>);
|
| 109 |
+
constexpr unordered_set& operator=(initializer_list<value_type>);
|
| 110 |
+
constexpr allocator_type get_allocator() const noexcept;
|
|
|
|
| 111 |
|
| 112 |
// iterators
|
| 113 |
+
constexpr iterator begin() noexcept;
|
| 114 |
+
constexpr const_iterator begin() const noexcept;
|
| 115 |
+
constexpr iterator end() noexcept;
|
| 116 |
+
constexpr const_iterator end() const noexcept;
|
| 117 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 118 |
+
constexpr const_iterator cend() const noexcept;
|
| 119 |
|
| 120 |
// capacity
|
| 121 |
+
constexpr bool empty() const noexcept;
|
| 122 |
+
constexpr size_type size() const noexcept;
|
| 123 |
+
constexpr size_type max_size() const noexcept;
|
| 124 |
|
| 125 |
+
// [unord.set.modifiers], modifiers
|
| 126 |
+
template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args);
|
| 127 |
+
template<class... Args>
|
| 128 |
+
constexpr iterator emplace_hint(const_iterator position, Args&&... args);
|
| 129 |
+
constexpr pair<iterator, bool> insert(const value_type& obj);
|
| 130 |
+
constexpr pair<iterator, bool> insert(value_type&& obj);
|
| 131 |
+
template<class K> constexpr pair<iterator, bool> insert(K&& obj);
|
| 132 |
+
constexpr iterator insert(const_iterator hint, const value_type& obj);
|
| 133 |
+
constexpr iterator insert(const_iterator hint, value_type&& obj);
|
| 134 |
+
template<class K> constexpr iterator insert(const_iterator hint, K&& obj);
|
| 135 |
+
template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last);
|
| 136 |
template<container-compatible-range<value_type> R>
|
| 137 |
+
constexpr void insert_range(R&& rg);
|
| 138 |
+
constexpr void insert(initializer_list<value_type>);
|
| 139 |
|
| 140 |
+
constexpr node_type extract(const_iterator position);
|
| 141 |
+
constexpr node_type extract(const key_type& x);
|
| 142 |
+
template<class K> constexpr node_type extract(K&& x);
|
| 143 |
+
constexpr insert_return_type insert(node_type&& nh);
|
| 144 |
+
constexpr iterator insert(const_iterator hint, node_type&& nh);
|
| 145 |
|
| 146 |
+
constexpr iterator erase(iterator position)
|
| 147 |
requires (!same_as<iterator, const_iterator>);
|
| 148 |
+
constexpr iterator erase(const_iterator position);
|
| 149 |
+
constexpr size_type erase(const key_type& k);
|
| 150 |
+
template<class K> constexpr size_type erase(K&& x);
|
| 151 |
+
constexpr iterator erase(const_iterator first, const_iterator last);
|
| 152 |
+
constexpr void swap(unordered_set&)
|
| 153 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 154 |
+
is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>);
|
| 155 |
+
constexpr void clear() noexcept;
|
|
|
|
| 156 |
|
| 157 |
template<class H2, class P2>
|
| 158 |
+
constexpr void merge(unordered_set<Key, H2, P2, Allocator>& source);
|
| 159 |
template<class H2, class P2>
|
| 160 |
+
constexpr void merge(unordered_set<Key, H2, P2, Allocator>&& source);
|
| 161 |
template<class H2, class P2>
|
| 162 |
+
constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>& source);
|
| 163 |
template<class H2, class P2>
|
| 164 |
+
constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);
|
| 165 |
|
| 166 |
// observers
|
| 167 |
+
constexpr hasher hash_function() const;
|
| 168 |
+
constexpr key_equal key_eq() const;
|
| 169 |
|
| 170 |
// set operations
|
| 171 |
+
constexpr iterator find(const key_type& k);
|
| 172 |
+
constexpr const_iterator find(const key_type& k) const;
|
| 173 |
template<class K>
|
| 174 |
+
constexpr iterator find(const K& k);
|
| 175 |
template<class K>
|
| 176 |
+
constexpr const_iterator find(const K& k) const;
|
| 177 |
+
constexpr size_type count(const key_type& k) const;
|
| 178 |
template<class K>
|
| 179 |
+
constexpr size_type count(const K& k) const;
|
| 180 |
+
constexpr bool contains(const key_type& k) const;
|
| 181 |
template<class K>
|
| 182 |
+
constexpr bool contains(const K& k) const;
|
| 183 |
+
constexpr pair<iterator, iterator> equal_range(const key_type& k);
|
| 184 |
+
constexpr pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
| 185 |
template<class K>
|
| 186 |
+
constexpr pair<iterator, iterator> equal_range(const K& k);
|
| 187 |
template<class K>
|
| 188 |
+
constexpr pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
| 189 |
|
| 190 |
// bucket interface
|
| 191 |
+
constexpr size_type bucket_count() const noexcept;
|
| 192 |
+
constexpr size_type max_bucket_count() const noexcept;
|
| 193 |
+
constexpr size_type bucket_size(size_type n) const;
|
| 194 |
+
constexpr size_type bucket(const key_type& k) const;
|
| 195 |
+
template<class K> constexpr size_type bucket(const K& k) const;
|
| 196 |
+
constexpr local_iterator begin(size_type n);
|
| 197 |
+
constexpr const_local_iterator begin(size_type n) const;
|
| 198 |
+
constexpr local_iterator end(size_type n);
|
| 199 |
+
constexpr const_local_iterator end(size_type n) const;
|
| 200 |
+
constexpr const_local_iterator cbegin(size_type n) const;
|
| 201 |
+
constexpr const_local_iterator cend(size_type n) const;
|
| 202 |
|
| 203 |
// hash policy
|
| 204 |
+
constexpr float load_factor() const noexcept;
|
| 205 |
+
constexpr float max_load_factor() const noexcept;
|
| 206 |
+
constexpr void max_load_factor(float z);
|
| 207 |
+
constexpr void rehash(size_type n);
|
| 208 |
+
constexpr void reserve(size_type n);
|
| 209 |
};
|
| 210 |
|
| 211 |
template<class InputIterator,
|
| 212 |
class Hash = hash<iter-value-type<InputIterator>>,
|
| 213 |
class Pred = equal_to<iter-value-type<InputIterator>>,
|
|
|
|
| 275 |
deduction guide.
|
| 276 |
|
| 277 |
#### Constructors <a id="unord.set.cnstr">[[unord.set.cnstr]]</a>
|
| 278 |
|
| 279 |
``` cpp
|
| 280 |
+
constexpr unordered_set() : unordered_set(size_type(see below)) { }
|
| 281 |
+
constexpr explicit unordered_set(size_type n, const hasher& hf = hasher(),
|
|
|
|
| 282 |
const key_equal& eql = key_equal(),
|
| 283 |
const allocator_type& a = allocator_type());
|
| 284 |
```
|
| 285 |
|
| 286 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
|
|
|
| 290 |
|
| 291 |
*Complexity:* Constant.
|
| 292 |
|
| 293 |
``` cpp
|
| 294 |
template<class InputIterator>
|
| 295 |
+
constexpr unordered_set(InputIterator f, InputIterator l,
|
| 296 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 297 |
const key_equal& eql = key_equal(),
|
| 298 |
const allocator_type& a = allocator_type());
|
| 299 |
template<container-compatible-range<value_type> R>
|
| 300 |
+
constexpr unordered_multiset(from_range_t, R&& rg,
|
| 301 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 302 |
const key_equal& eql = key_equal(),
|
| 303 |
const allocator_type& a = allocator_type());
|
| 304 |
+
constexpr unordered_set(initializer_list<value_type> il,
|
| 305 |
+
size_type n = see below, const hasher& hf = hasher(),
|
|
|
|
| 306 |
const key_equal& eql = key_equal(),
|
| 307 |
const allocator_type& a = allocator_type());
|
| 308 |
```
|
| 309 |
|
| 310 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
|
|
|
| 317 |
|
| 318 |
#### Erasure <a id="unord.set.erasure">[[unord.set.erasure]]</a>
|
| 319 |
|
| 320 |
``` cpp
|
| 321 |
template<class K, class H, class P, class A, class Predicate>
|
| 322 |
+
constexpr typename unordered_set<K, H, P, A>::size_type
|
| 323 |
erase_if(unordered_set<K, H, P, A>& c, Predicate pred);
|
| 324 |
```
|
| 325 |
|
| 326 |
*Effects:* Equivalent to:
|
| 327 |
|
|
|
|
| 335 |
}
|
| 336 |
}
|
| 337 |
return original_size - c.size();
|
| 338 |
```
|
| 339 |
|
| 340 |
+
#### Modifiers <a id="unord.set.modifiers">[[unord.set.modifiers]]</a>
|
| 341 |
+
|
| 342 |
+
``` cpp
|
| 343 |
+
template<class K> constexpr pair<iterator, bool> insert(K&& obj);
|
| 344 |
+
template<class K> constexpr iterator insert(const_iterator hint, K&& obj);
|
| 345 |
+
```
|
| 346 |
+
|
| 347 |
+
*Constraints:* The *qualified-id*s `Hash::is_transparent` and
|
| 348 |
+
`Pred::is_transparent` are valid and denote types. For the second
|
| 349 |
+
overload, `is_convertible_v<K&&, const_iterator>` and
|
| 350 |
+
`is_convertible_v<K&&, iterator>` are both `false`.
|
| 351 |
+
|
| 352 |
+
*Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into
|
| 353 |
+
`unordered_set` from `std::forward<K> (obj)`.
|
| 354 |
+
|
| 355 |
+
*Effects:* If the set already contains an element that is equivalent to
|
| 356 |
+
`obj`, there is no effect. Otherwise, let `h` be `hash_function()(obj)`.
|
| 357 |
+
Constructs an object `u` of type `value_type` with
|
| 358 |
+
`std::forward<K>(obj)`. If `hash_function()(u) != h || contains(u)` is
|
| 359 |
+
`true`, the behavior is undefined. Inserts `u` into `*this`.
|
| 360 |
+
|
| 361 |
+
*Returns:* For the first overload, the `bool` component of the returned
|
| 362 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 363 |
+
iterator points to the set element that is equivalent to `obj`.
|
| 364 |
+
|
| 365 |
+
*Complexity:* Average case constant, worst case linear.
|
| 366 |
+
|