tmp/tmpaadapnh6/{from.md → to.md}
RENAMED
|
@@ -5,18 +5,18 @@
|
|
| 5 |
An `unordered_map` is an unordered associative container that supports
|
| 6 |
unique keys (an `unordered_map` contains at most one of each key value)
|
| 7 |
and that associates values of another type `mapped_type` with the keys.
|
| 8 |
The `unordered_map` class supports forward iterators.
|
| 9 |
|
| 10 |
-
An `unordered_map` meets all of the requirements of a container
|
| 11 |
-
|
| 12 |
-
[[container.alloc.
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
`
|
| 16 |
-
`Key
|
| 17 |
-
`pair<const Key, T>`.
|
| 18 |
|
| 19 |
Subclause [[unord.map]] only describes operations on `unordered_map`
|
| 20 |
that are not described in one of the requirement tables, or for which
|
| 21 |
there is additional semantic information.
|
| 22 |
|
|
@@ -38,12 +38,12 @@ namespace std {
|
|
| 38 |
using allocator_type = Allocator;
|
| 39 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 40 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 41 |
using reference = value_type&;
|
| 42 |
using const_reference = const value_type&;
|
| 43 |
-
using size_type = implementation-defined; // see [container.requirements]
|
| 44 |
-
using difference_type = implementation-defined; // see [container.requirements]
|
| 45 |
|
| 46 |
using iterator = implementation-defined // type of unordered_map::iterator; // see [container.requirements]
|
| 47 |
using const_iterator = implementation-defined // type of unordered_map::const_iterator; // see [container.requirements]
|
| 48 |
using local_iterator = implementation-defined // type of unordered_map::local_iterator; // see [container.requirements]
|
| 49 |
using const_local_iterator = implementation-defined // type of unordered_map::const_local_iterator; // see [container.requirements]
|
|
@@ -60,15 +60,20 @@ namespace std {
|
|
| 60 |
unordered_map(InputIterator f, InputIterator l,
|
| 61 |
size_type n = see below,
|
| 62 |
const hasher& hf = hasher(),
|
| 63 |
const key_equal& eql = key_equal(),
|
| 64 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
unordered_map(const unordered_map&);
|
| 66 |
unordered_map(unordered_map&&);
|
| 67 |
explicit unordered_map(const Allocator&);
|
| 68 |
-
unordered_map(const unordered_map&, const Allocator&);
|
| 69 |
-
unordered_map(unordered_map&&, const Allocator&);
|
| 70 |
unordered_map(initializer_list<value_type> il,
|
| 71 |
size_type n = see below,
|
| 72 |
const hasher& hf = hasher(),
|
| 73 |
const key_equal& eql = key_equal(),
|
| 74 |
const allocator_type& a = allocator_type());
|
|
@@ -81,10 +86,16 @@ namespace std {
|
|
| 81 |
: unordered_map(f, l, n, hasher(), key_equal(), a) { }
|
| 82 |
template<class InputIterator>
|
| 83 |
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 84 |
const allocator_type& a)
|
| 85 |
: unordered_map(f, l, n, hf, key_equal(), a) { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 87 |
: unordered_map(il, n, hasher(), key_equal(), a) { }
|
| 88 |
unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 89 |
const allocator_type& a)
|
| 90 |
: unordered_map(il, n, hf, key_equal(), a) { }
|
|
@@ -118,14 +129,17 @@ namespace std {
|
|
| 118 |
template<class P> pair<iterator, bool> insert(P&& obj);
|
| 119 |
iterator insert(const_iterator hint, const value_type& obj);
|
| 120 |
iterator insert(const_iterator hint, value_type&& obj);
|
| 121 |
template<class P> iterator insert(const_iterator hint, P&& obj);
|
| 122 |
template<class InputIterator> void insert(InputIterator first, InputIterator last);
|
|
|
|
|
|
|
| 123 |
void insert(initializer_list<value_type>);
|
| 124 |
|
| 125 |
node_type extract(const_iterator position);
|
| 126 |
node_type extract(const key_type& x);
|
|
|
|
| 127 |
insert_return_type insert(node_type&& nh);
|
| 128 |
iterator insert(const_iterator hint, node_type&& nh);
|
| 129 |
|
| 130 |
template<class... Args>
|
| 131 |
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
|
|
@@ -145,10 +159,11 @@ namespace std {
|
|
| 145 |
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
|
| 146 |
|
| 147 |
iterator erase(iterator position);
|
| 148 |
iterator erase(const_iterator position);
|
| 149 |
size_type erase(const key_type& k);
|
|
|
|
| 150 |
iterator erase(const_iterator first, const_iterator last);
|
| 151 |
void swap(unordered_map&)
|
| 152 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 153 |
is_nothrow_swappable_v<Hash> &&
|
| 154 |
is_nothrow_swappable_v<Pred>);
|
|
@@ -172,11 +187,10 @@ namespace std {
|
|
| 172 |
const_iterator find(const key_type& k) const;
|
| 173 |
template<class K>
|
| 174 |
iterator find(const K& k);
|
| 175 |
template<class K>
|
| 176 |
const_iterator find(const K& k) const;
|
| 177 |
-
template<class K>
|
| 178 |
size_type count(const key_type& k) const;
|
| 179 |
template<class K>
|
| 180 |
size_type count(const K& k) const;
|
| 181 |
bool contains(const key_type& k) const;
|
| 182 |
template<class K>
|
|
@@ -221,10 +235,17 @@ namespace std {
|
|
| 221 |
unordered_map(InputIterator, InputIterator, typename see below::size_type = see below,
|
| 222 |
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
| 223 |
-> unordered_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Hash, Pred,
|
| 224 |
Allocator>;
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
template<class Key, class T, class Hash = hash<Key>,
|
| 227 |
class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
|
| 228 |
unordered_map(initializer_list<pair<Key, T>>,
|
| 229 |
typename see below::size_type = see below, Hash = Hash(),
|
| 230 |
Pred = Pred(), Allocator = Allocator())
|
|
@@ -245,10 +266,25 @@ namespace std {
|
|
| 245 |
template<class InputIterator, class Hash, class Allocator>
|
| 246 |
unordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
|
| 247 |
-> unordered_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Hash,
|
| 248 |
equal_to<iter-key-type<InputIterator>>, Allocator>;
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
template<class Key, class T, class Allocator>
|
| 251 |
unordered_map(initializer_list<pair<Key, T>>, typename see below::size_type,
|
| 252 |
Allocator)
|
| 253 |
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
|
| 254 |
|
|
@@ -258,16 +294,10 @@ namespace std {
|
|
| 258 |
|
| 259 |
template<class Key, class T, class Hash, class Allocator>
|
| 260 |
unordered_map(initializer_list<pair<Key, T>>, typename see below::size_type, Hash,
|
| 261 |
Allocator)
|
| 262 |
-> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>;
|
| 263 |
-
|
| 264 |
-
// swap
|
| 265 |
-
template<class Key, class T, class Hash, class Pred, class Alloc>
|
| 266 |
-
void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
|
| 267 |
-
unordered_map<Key, T, Hash, Pred, Alloc>& y)
|
| 268 |
-
noexcept(noexcept(x.swap(y)));
|
| 269 |
}
|
| 270 |
```
|
| 271 |
|
| 272 |
A `size_type` parameter type in an `unordered_map` deduction guide
|
| 273 |
refers to the `size_type` member type of the type deduced by the
|
|
@@ -295,10 +325,16 @@ template<class InputIterator>
|
|
| 295 |
unordered_map(InputIterator f, InputIterator l,
|
| 296 |
size_type n = see below,
|
| 297 |
const hasher& hf = hasher(),
|
| 298 |
const key_equal& eql = key_equal(),
|
| 299 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
unordered_map(initializer_list<value_type> il,
|
| 301 |
size_type n = see below,
|
| 302 |
const hasher& hf = hasher(),
|
| 303 |
const key_equal& eql = key_equal(),
|
| 304 |
const allocator_type& a = allocator_type());
|
|
@@ -306,12 +342,11 @@ unordered_map(initializer_list<value_type> il,
|
|
| 306 |
|
| 307 |
*Effects:* Constructs an empty `unordered_map` using the specified hash
|
| 308 |
function, key equality predicate, and allocator, and using at least `n`
|
| 309 |
buckets. If `n` is not provided, the number of buckets is
|
| 310 |
*implementation-defined*. Then inserts elements from the range \[`f`,
|
| 311 |
-
`l`)
|
| 312 |
-
for the second form. `max_load_factor()` returns `1.0`.
|
| 313 |
|
| 314 |
*Complexity:* Average case linear, worst case quadratic.
|
| 315 |
|
| 316 |
#### Element access <a id="unord.map.elem">[[unord.map.elem]]</a>
|
| 317 |
|
|
@@ -323,11 +358,12 @@ mapped_type& operator[](const key_type& k);
|
|
| 323 |
|
| 324 |
``` cpp
|
| 325 |
mapped_type& operator[](key_type&& k);
|
| 326 |
```
|
| 327 |
|
| 328 |
-
*Effects:* Equivalent to:
|
|
|
|
| 329 |
|
| 330 |
``` cpp
|
| 331 |
mapped_type& at(const key_type& k);
|
| 332 |
const mapped_type& at(const key_type& k) const;
|
| 333 |
```
|
|
|
|
| 5 |
An `unordered_map` is an unordered associative container that supports
|
| 6 |
unique keys (an `unordered_map` contains at most one of each key value)
|
| 7 |
and that associates values of another type `mapped_type` with the keys.
|
| 8 |
The `unordered_map` class supports forward iterators.
|
| 9 |
|
| 10 |
+
An `unordered_map` 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_map` supports
|
| 15 |
+
the `a_uniq` operations in that table, not the `a_eq` operations. For an
|
| 16 |
+
`unordered_map<Key, T>` the `key_type` is `Key`, the `mapped_type` is
|
| 17 |
+
`T`, and the `value_type` is `pair<const Key, T>`.
|
| 18 |
|
| 19 |
Subclause [[unord.map]] only describes operations on `unordered_map`
|
| 20 |
that are not described in one of the requirement tables, or for which
|
| 21 |
there is additional semantic information.
|
| 22 |
|
|
|
|
| 38 |
using allocator_type = Allocator;
|
| 39 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 40 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 41 |
using reference = value_type&;
|
| 42 |
using const_reference = const value_type&;
|
| 43 |
+
using size_type = implementation-defined // type of unordered_map::size_type; // see [container.requirements]
|
| 44 |
+
using difference_type = implementation-defined // type of unordered_map::difference_type; // see [container.requirements]
|
| 45 |
|
| 46 |
using iterator = implementation-defined // type of unordered_map::iterator; // see [container.requirements]
|
| 47 |
using const_iterator = implementation-defined // type of unordered_map::const_iterator; // see [container.requirements]
|
| 48 |
using local_iterator = implementation-defined // type of unordered_map::local_iterator; // see [container.requirements]
|
| 49 |
using const_local_iterator = implementation-defined // type of unordered_map::const_local_iterator; // see [container.requirements]
|
|
|
|
| 60 |
unordered_map(InputIterator f, InputIterator l,
|
| 61 |
size_type n = see below,
|
| 62 |
const hasher& hf = hasher(),
|
| 63 |
const key_equal& eql = key_equal(),
|
| 64 |
const allocator_type& a = allocator_type());
|
| 65 |
+
|
| 66 |
+
template<container-compatible-range<value_type> R>
|
| 67 |
+
unordered_map(from_range_t, R&& rg, size_type n = see below,
|
| 68 |
+
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
|
| 69 |
+
const allocator_type& a = allocator_type());
|
| 70 |
unordered_map(const unordered_map&);
|
| 71 |
unordered_map(unordered_map&&);
|
| 72 |
explicit unordered_map(const Allocator&);
|
| 73 |
+
unordered_map(const unordered_map&, const type_identity_t<Allocator>&);
|
| 74 |
+
unordered_map(unordered_map&&, const type_identity_t<Allocator>&);
|
| 75 |
unordered_map(initializer_list<value_type> il,
|
| 76 |
size_type n = see below,
|
| 77 |
const hasher& hf = hasher(),
|
| 78 |
const key_equal& eql = key_equal(),
|
| 79 |
const allocator_type& a = allocator_type());
|
|
|
|
| 86 |
: unordered_map(f, l, n, hasher(), key_equal(), a) { }
|
| 87 |
template<class InputIterator>
|
| 88 |
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 89 |
const allocator_type& a)
|
| 90 |
: unordered_map(f, l, n, hf, key_equal(), a) { }
|
| 91 |
+
template<container-compatible-range<value_type> R>
|
| 92 |
+
unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a)
|
| 93 |
+
: unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { }
|
| 94 |
+
template<container-compatible-range<value_type> R>
|
| 95 |
+
unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
|
| 96 |
+
: unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }
|
| 97 |
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 98 |
: unordered_map(il, n, hasher(), key_equal(), a) { }
|
| 99 |
unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 100 |
const allocator_type& a)
|
| 101 |
: unordered_map(il, n, hf, key_equal(), a) { }
|
|
|
|
| 129 |
template<class P> pair<iterator, bool> insert(P&& obj);
|
| 130 |
iterator insert(const_iterator hint, const value_type& obj);
|
| 131 |
iterator insert(const_iterator hint, value_type&& obj);
|
| 132 |
template<class P> iterator insert(const_iterator hint, P&& obj);
|
| 133 |
template<class InputIterator> void insert(InputIterator first, InputIterator last);
|
| 134 |
+
template<container-compatible-range<value_type> R>
|
| 135 |
+
void insert_range(R&& rg);
|
| 136 |
void insert(initializer_list<value_type>);
|
| 137 |
|
| 138 |
node_type extract(const_iterator position);
|
| 139 |
node_type extract(const key_type& x);
|
| 140 |
+
template<class K> node_type extract(K&& x);
|
| 141 |
insert_return_type insert(node_type&& nh);
|
| 142 |
iterator insert(const_iterator hint, node_type&& nh);
|
| 143 |
|
| 144 |
template<class... Args>
|
| 145 |
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
|
|
|
|
| 159 |
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
|
| 160 |
|
| 161 |
iterator erase(iterator position);
|
| 162 |
iterator erase(const_iterator position);
|
| 163 |
size_type erase(const key_type& k);
|
| 164 |
+
template<class K> size_type erase(K&& x);
|
| 165 |
iterator erase(const_iterator first, const_iterator last);
|
| 166 |
void swap(unordered_map&)
|
| 167 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 168 |
is_nothrow_swappable_v<Hash> &&
|
| 169 |
is_nothrow_swappable_v<Pred>);
|
|
|
|
| 187 |
const_iterator find(const key_type& k) const;
|
| 188 |
template<class K>
|
| 189 |
iterator find(const K& k);
|
| 190 |
template<class K>
|
| 191 |
const_iterator find(const K& k) const;
|
|
|
|
| 192 |
size_type count(const key_type& k) const;
|
| 193 |
template<class K>
|
| 194 |
size_type count(const K& k) const;
|
| 195 |
bool contains(const key_type& k) const;
|
| 196 |
template<class K>
|
|
|
|
| 235 |
unordered_map(InputIterator, InputIterator, typename see below::size_type = see below,
|
| 236 |
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
| 237 |
-> unordered_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Hash, Pred,
|
| 238 |
Allocator>;
|
| 239 |
|
| 240 |
+
template<ranges::input_range R, class Hash = hash<range-key-type<R>>,
|
| 241 |
+
class Pred = equal_to<range-key-type<R>>,
|
| 242 |
+
class Allocator = allocator<range-to-alloc-type<R>>>
|
| 243 |
+
unordered_map(from_range_t, R&&, typename see below::size_type = see below,
|
| 244 |
+
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
| 245 |
+
-> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>;
|
| 246 |
+
|
| 247 |
template<class Key, class T, class Hash = hash<Key>,
|
| 248 |
class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
|
| 249 |
unordered_map(initializer_list<pair<Key, T>>,
|
| 250 |
typename see below::size_type = see below, Hash = Hash(),
|
| 251 |
Pred = Pred(), Allocator = Allocator())
|
|
|
|
| 266 |
template<class InputIterator, class Hash, class Allocator>
|
| 267 |
unordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
|
| 268 |
-> unordered_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Hash,
|
| 269 |
equal_to<iter-key-type<InputIterator>>, Allocator>;
|
| 270 |
|
| 271 |
+
template<ranges::input_range R, class Allocator>
|
| 272 |
+
unordered_map(from_range_t, R&&, typename see below::size_type, Allocator)
|
| 273 |
+
-> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
|
| 274 |
+
equal_to<range-key-type<R>>, Allocator>;
|
| 275 |
+
|
| 276 |
+
template<ranges::input_range R, class Allocator>
|
| 277 |
+
unordered_map(from_range_t, R&&, Allocator)
|
| 278 |
+
-> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
|
| 279 |
+
equal_to<range-key-type<R>>, Allocator>;
|
| 280 |
+
|
| 281 |
+
template<ranges::input_range R, class Hash, class Allocator>
|
| 282 |
+
unordered_map(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
|
| 283 |
+
-> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash,
|
| 284 |
+
equal_to<range-key-type<R>>, Allocator>;
|
| 285 |
+
|
| 286 |
template<class Key, class T, class Allocator>
|
| 287 |
unordered_map(initializer_list<pair<Key, T>>, typename see below::size_type,
|
| 288 |
Allocator)
|
| 289 |
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
|
| 290 |
|
|
|
|
| 294 |
|
| 295 |
template<class Key, class T, class Hash, class Allocator>
|
| 296 |
unordered_map(initializer_list<pair<Key, T>>, typename see below::size_type, Hash,
|
| 297 |
Allocator)
|
| 298 |
-> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
}
|
| 300 |
```
|
| 301 |
|
| 302 |
A `size_type` parameter type in an `unordered_map` deduction guide
|
| 303 |
refers to the `size_type` member type of the type deduced by the
|
|
|
|
| 325 |
unordered_map(InputIterator f, InputIterator l,
|
| 326 |
size_type n = see below,
|
| 327 |
const hasher& hf = hasher(),
|
| 328 |
const key_equal& eql = key_equal(),
|
| 329 |
const allocator_type& a = allocator_type());
|
| 330 |
+
template<container-compatible-range<value_type> R>
|
| 331 |
+
unordered_map(from_range_t, R&& rg,
|
| 332 |
+
size_type n = see below,
|
| 333 |
+
const hasher& hf = hasher(),
|
| 334 |
+
const key_equal& eql = key_equal(),
|
| 335 |
+
const allocator_type& a = allocator_type());
|
| 336 |
unordered_map(initializer_list<value_type> il,
|
| 337 |
size_type n = see below,
|
| 338 |
const hasher& hf = hasher(),
|
| 339 |
const key_equal& eql = key_equal(),
|
| 340 |
const allocator_type& a = allocator_type());
|
|
|
|
| 342 |
|
| 343 |
*Effects:* Constructs an empty `unordered_map` using the specified hash
|
| 344 |
function, key equality predicate, and allocator, and using at least `n`
|
| 345 |
buckets. If `n` is not provided, the number of buckets is
|
| 346 |
*implementation-defined*. Then inserts elements from the range \[`f`,
|
| 347 |
+
`l`), `rg`, or `il`, respectively. `max_load_factor()` returns `1.0`.
|
|
|
|
| 348 |
|
| 349 |
*Complexity:* Average case linear, worst case quadratic.
|
| 350 |
|
| 351 |
#### Element access <a id="unord.map.elem">[[unord.map.elem]]</a>
|
| 352 |
|
|
|
|
| 358 |
|
| 359 |
``` cpp
|
| 360 |
mapped_type& operator[](key_type&& k);
|
| 361 |
```
|
| 362 |
|
| 363 |
+
*Effects:* Equivalent to:
|
| 364 |
+
`return try_emplace(std::move(k)).first->second;`
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
mapped_type& at(const key_type& k);
|
| 368 |
const mapped_type& at(const key_type& k) const;
|
| 369 |
```
|