Debian Codegraph @

headers/map

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