forked from p12tic/cppreference-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap
More file actions
555 lines (443 loc) · 16.8 KB
/
map
File metadata and controls
555 lines (443 loc) · 16.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
/* Copyright (C) 2015 Povilas Kanapickas <povilas@radix.lt>
This file is part of cppreference-doc
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
Unported License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/
#ifndef CPPREFERENCE_MAP_H
#define CPPREFERENCE_MAP_H
#if CPPREFERENCE_STDVER >= 2011
#include <initializer_list>
#endif
#include <cstddef> // for size_t, ptrdiff_t
#include <iterator> // for std::reverse_iterator
#include <functional> // for less
#include <memory> // for std::allocator
#include <utility> // for std::pair
namespace std {
template <
class Key,
class T,
class Compare = std::less<Key>,
class Allocator = std::allocator<Key>
> class map {
public:
typedef Key key_type;
typedef T mapped_type;
typedef pair<const Key, T> value_type;
typedef Compare key_compare;
typedef Allocator allocator_type;
typedef size_t size_type; // actual type unspecified
typedef ptrdiff_t difference_type; // actual type not specified
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef const value_type* const_pointer;
#elif CPPREFERENCE_STDVER <2011
typedef typename Allocator::reference reference;
typedef typename Allocator::const_reference const_reference;
typedef typename Allocator::pointer pointer;
typedef typename Allocator::const_pointer const_pointer;
#else
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename std::allocator_traits<Allocator>::pointer pointer;
typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
#endif
typedef value_type* iterator; // actual type is unspecified
typedef const value_type* const_iterator; // actual type is unspecified
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// constructor
class value_compare {
public:
typedef bool result_type;
typedef value_type first_argument_type ;
typedef value_type second_argument_type;
bool operator()(const value_type& lhs, const value_type& rhs) const;
protected:
value_compare(Compare c);
Compare comp;
};
map();
explicit map(const Compare& comp,
const Allocator& alloc = Allocator());
#if CPPREFERENCE_STDVER>= 2011
explicit map(const Allocator& alloc);
#endif
template<class InputIt>
map(InputIt first, InputIt last,
const Compare& comp = Compare(),
const Allocator& alloc = Allocator());
#if CPPREFERENCE_STDVER>= 2014
template<class InputIt>
map(InputIt first, InputIt last, const Allocator& alloc);
#endif
map(const map& other);
#if CPPREFERENCE_STDVER>= 2011
map(const map& other, const Allocator& alloc);
#endif
#if CPPREFERENCE_STDVER>= 2011
map(map&& other);
map(map&& other, const Allocator& alloc);
map(std::initializer_list<value_type> init,
const Compare& comp = Compare(),
const Allocator& alloc = Allocator());
#endif
#if CPPREFERENCE_STDVER>= 2014
map(std::initializer_list<value_type> init, const Allocator& alloc);
#endif
~map();
map& operator=(const map& other);
#if CPPREFERENCE_STDVER>= 2011
map& operator=(map&& other);
map& operator=(initializer_list<value_type> ilist);
#endif
void assign(size_type count, const value_type& value);
template <class InputIt>
void assign(InputIt first, InputIt last);
#if CPPREFERENCE_STDVER>= 2011
void assign(std::initializer_list<value_type> ilist);
#endif
allocator_type get_allocator() const;
// element access
T& operator[](const Key& key);
#if CPPREFERENCE_STDVER>= 2011
T& operator[](Key&& key);
T& at(const Key& key);
const T& at(const Key& key) const;
#endif
// iterators
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
#if CPPREFERENCE_STDVER>= 2011
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
#endif
// capacity
bool empty() const;
size_type size() const;
size_type max_size() const;
// modifiers
void clear();
std::pair<iterator, bool> insert(const value_type& value);
#if CPPREFERENCE_STDVER <2011
iterator insert(iterator hint, const value_type& value);
#else
iterator insert(const_iterator hint, const value_type& value);
template<class P>
std::pair<iterator, bool> insert(P&& value);
std::pair<iterator, bool> insert(value_type&& value);
iterator insert(const_iterator hint, value_type&& value);
void insert(std::initializer_list<value_type> ilist);
#endif
template<class InputIt>
void insert(InputIt first, InputIt last);
#if CPPREFERENCE_STDVER >= 2017
template<class M>
std::pair<iterator, bool> insert_or_assign(const Key& key, M&& obj);
template<class M>
std::pair<iterator, bool> insert_or_assign(Key&& key, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj);
#endif
#if CPPREFERENCE_STDVER>= 2011
template<class... Args>
std::pair<iterator, bool> emplace(Args&& ... args);
template <class... Args>
iterator emplace_hint(const_iterator hint, Args&& ... args);
#endif
#if CPPREFERENCE_STDVER >= 2017
template<class... Args>
std::pair<iterator, bool> try_emplace(const Key& key, Args&& ... args);
template<class... Args>
std::pair<iterator, bool> try_emplace(Key&& key, Args&& ... args);
template<class... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, const Key& key, Args&& ... args);
template<class... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, Key&& key, Args&& ... args);
#endif
#if CPPREFERENCE_STDVER <2011
void erase(iterator pos);
void erase(iterator first, iterator last);
#else
iterator erase(const_iterator pos);
iterator erase(const_iterator first, const_iterator last);
#endif
size_type erase(const key_type& key);
void swap(map& other);
// lookup
size_type count(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
size_type count(const K& x) const;
#endif
iterator find(const Key& key);
const_iterator find(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K> iterator find(const K& x);
template<class K> const_iterator find(const K& x) const;
#endif
std::pair<iterator, iterator> equal_range(const Key& key);
std::pair<const_iterator, const_iterator> equal_range(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
std::pair<iterator, iterator> equal_range(const K& x);
template<class K>
std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
#endif
iterator lower_bound(const Key& key);
const_iterator lower_bound(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
iterator lower_bound(const K& x);
template<class K>
const_iterator lower_bound(const K& x) const;
#endif
iterator upper_bound(const Key& key);
const_iterator upper_bound(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
iterator upper_bound(const K& x);
template<class K>
const_iterator upper_bound(const K& x) const;
#endif
// observers
key_compare key_comp() const;
value_compare value_comp() const;
};
template<class Key, class T, class Compare, class Alloc>
bool operator==(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator!=(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator<(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator<=(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator>(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator>=(const map<Key, T, Compare, Alloc>& lhs,
const map<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
void swap(map<Key, T, Compare, Alloc>& lhs,
map<Key, T, Compare, Alloc>& rhs);
template <
class Key,
class T,
class Compare = std::less<Key>,
class Allocator = std::allocator<Key>
> class multimap {
public:
typedef Key key_type;
typedef T mapped_type;
typedef pair<const Key, T> value_type;
typedef Compare key_compare;
typedef Allocator allocator_type;
typedef size_t size_type; // actual type unspecified
typedef ptrdiff_t difference_type; // actual type not specified
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef const value_type* const_pointer;
#elif CPPREFERENCE_STDVER <2011
typedef typename Allocator::reference reference;
typedef typename Allocator::const_reference const_reference;
typedef typename Allocator::pointer pointer;
typedef typename Allocator::const_pointer const_pointer;
#else
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename std::allocator_traits<Allocator>::pointer pointer;
typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
#endif
typedef T* iterator; // actual type is unspecified
typedef const T* const_iterator; // actual type is unspecified
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// constructor
class value_compare {
public:
typedef bool result_type;
typedef value_type first_argument_type;
typedef value_type second_argument_type;
bool operator()(const value_type& lhs, const value_type& rhs) const;
protected:
value_compare(Compare c);
Compare comp;
};
multimap();
explicit multimap(const Compare& comp,
const Allocator& alloc = Allocator());
#if CPPREFERENCE_STDVER>= 2011
explicit multimap(const Allocator& alloc);
#endif
template<class InputIt>
multimap(InputIt first, InputIt last,
const Compare& comp = Compare(),
const Allocator& alloc = Allocator());
#if CPPREFERENCE_STDVER>= 2014
template<class InputIt>
multimap(InputIt first, InputIt last, const Allocator& alloc);
#endif
multimap(const multimap& other);
#if CPPREFERENCE_STDVER>= 2011
multimap(const multimap& other, const Allocator& alloc);
#endif
#if CPPREFERENCE_STDVER>= 2011
multimap(multimap&& other);
multimap(multimap&& other, const Allocator& alloc);
multimap(std::initializer_list<value_type> init,
const Compare& comp = Compare(),
const Allocator& alloc = Allocator());
#endif
#if CPPREFERENCE_STDVER>= 2014
multimap(std::initializer_list<value_type> init, const Allocator& alloc);
#endif
~multimap();
multimap& operator=(const multimap& other);
#if CPPREFERENCE_STDVER>= 2011
multimap& operator=(multimap&& other);
multimap& operator=(initializer_list<value_type> ilist);
#endif
void assign(size_type count, const value_type& value);
template <class InputIt>
void assign(InputIt first, InputIt last);
#if CPPREFERENCE_STDVER>= 2011
void assign(std::initializer_list<value_type> ilist);
#endif
allocator_type get_allocator() const;
// iterators
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
#if CPPREFERENCE_STDVER>= 2011
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
#endif
// capacity
bool empty() const;
size_type size() const;
size_type max_size() const;
// modifiers
void clear();
std::pair<iterator, bool> insert(const value_type& value);
#if CPPREFERENCE_STDVER <2011
iterator insert(iterator hint, const value_type& value);
#else
iterator insert(const_iterator hint, const value_type& value);
template<class P>
std::pair<iterator, bool> insert(P&& value);
std::pair<iterator, bool> insert(value_type&& value);
iterator insert(const_iterator hint, value_type&& value);
void insert(std::initializer_list<value_type> ilist);
#endif
template<class InputIt>
void insert(InputIt first, InputIt last);
#if CPPREFERENCE_STDVER>= 2011
template<class... Args>
std::pair<iterator, bool> emplace(Args&& ... args);
template <class... Args>
iterator emplace_hint(const_iterator hint, Args&& ... args);
#endif
#if CPPREFERENCE_STDVER <2011
void erase(iterator pos);
void erase(iterator first, iterator last);
#else
iterator erase(const_iterator pos);
iterator erase(const_iterator first, const_iterator last);
#endif
size_type erase(const key_type& key);
void swap(multimap& other);
// lookup
size_type count(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
size_type count(const K& x) const;
#endif
iterator find(const Key& key);
const_iterator find(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K> iterator find(const K& x);
template<class K> const_iterator find(const K& x) const;
#endif
std::pair<iterator, iterator> equal_range(const Key& key);
std::pair<const_iterator, const_iterator> equal_range(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
std::pair<iterator, iterator> equal_range(const K& x);
template<class K>
std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
#endif
iterator lower_bound(const Key& key);
const_iterator lower_bound(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
iterator lower_bound(const K& x);
template<class K>
const_iterator lower_bound(const K& x) const;
#endif
iterator upper_bound(const Key& key);
const_iterator upper_bound(const Key& key) const;
#if CPPREFERENCE_STDVER>= 2014
template<class K>
iterator upper_bound(const K& x);
template<class K>
const_iterator upper_bound(const K& x) const;
#endif
// observers
key_compare key_comp() const;
value_compare value_comp() const;
};
template<class Key, class T, class Compare, class Alloc>
bool operator==(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator!=(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator<(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator<=(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator>(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
bool operator>=(const multimap<Key, T, Compare, Alloc>& lhs,
const multimap<Key, T, Compare, Alloc>& rhs);
template<class Key, class T, class Compare, class Alloc>
void swap(multimap<Key, T, Compare, Alloc>& lhs,
multimap<Key, T, Compare, Alloc>& rhs);
} // namespace std
#endif // CPPREFERENCE_MAP_H