Debian Codegraph @

headers/set

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_SET_H
17 #define CPPREFERENCE_SET_H
18
19 namespace std {
20
21 template <
22 class Key,
23 class Compare = std::less<Key>,
24 class Allocator = std::allocator<Key>
25 > class set {
26 public:
27 typedef Key key_type;
28 typedef Key value_type;
29 typedef Compare key_compare;
30 typedef Compare value_compare;
31 typedef Allocator allocator_type;
32 typedef size_t size_type; // actual type unspecified
33 typedef ptrdiff_t difference_type; // actual type not specified
34 #if CPPREFERENCE_SIMPLIFY_TYPEDEFS
35 typedef value_type& reference;
36 typedef const value_type& const_reference;
37 typedef value_type* pointer;
38 typedef const value_type* const_pointer;
39 #elif CPPREFERENCE_STDVER <2011
40 typedef typename Allocator::reference reference;
41 typedef typename Allocator::const_reference const_reference;
42 typedef typename Allocator::pointer pointer;
43 typedef typename Allocator::const_pointer const_pointer;
44 #else
45 typedef value_type& reference;
46 typedef const value_type& const_reference;
47 typedef typename std::allocator_traits<Allocator>::pointer pointer;
48 typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
49 #endif
50 typedef T* iterator; // actual type is unspecified
51 typedef const T* const_iterator; // actual type is unspecified
52 typedef std::reverse_iterator<iterator> reverse_iterator;
53 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
54
55 // constructor
56
57
58 #if CPPREFERENCE_STDVER <2014
59 explicit set(const Compare& comp = Compare(),
60 const Allocator& alloc = Allocator());
61 #else
62 set();
63 explicit set(const Compare& comp,
64 const Allocator& alloc = Allocator());
65 #endif
66
67 #if CPPREFERENCE_STDVER>= 2011
68 explicit set(const Allocator& alloc);
69 #endif
70
71 template<class InputIt>
72 set(InputIt first, InputIt last,
73 const Compare& comp = Compare(),
74 const Allocator& alloc = Allocator());
75
76 #if CPPREFERENCE_STDVER>= 2014
77 template<class InputIt>
78 set(InputIt first, InputIt last, const Allocator& alloc);
79 #endif
80
81 set(const set& other);
82
83 #if CPPREFERENCE_STDVER>= 2011
84 set(const set& other, const Allocator& alloc);
85 #endif
86
87 #if CPPREFERENCE_STDVER>= 2011
88 set(set&& other);
89 set(set&& other, const Allocator& alloc);
90
91 set(std::initializer_list<value_type> init,
92 const Compare& comp = Compare(),
93 const Allocator& alloc = Allocator());
94 #endif
95
96 #if CPPREFERENCE_STDVER>= 2014
97 set(std::initializer_list<value_type> init, const Allocator& alloc);
98 #endif
99
100 ~set();
101
102 set& operator=(const set& other);
103 #if CPPREFERENCE_STDVER>= 2011
104 set& operator=(set&& other);
105 set& operator=(initializer_list<value_type> ilist);
106 #endif
107
108 allocator_type get_allocator() const;
109
110 // iterators
111 iterator begin();
112 const_iterator begin() const;
113 iterator end();
114 const_iterator end() const;
115
116 reverse_iterator rbegin();
117 const_reverse_iterator rbegin() const;
118 reverse_iterator rend();
119 const_reverse_iterator rend() const;
120
121 #if CPPREFERENCE_STDVER>= 2011
122 const_iterator cbegin() const;
123 const_iterator cend() const;
124 const_reverse_iterator crbegin() const;
125 const_reverse_iterator crend() const;
126 #endif
127
128 // capacity
129 bool empty() const;
130 size_type size() const;
131 size_type max_size() const;
132
133 // modifiers
134 void clear();
135
136 std::pair<iterator, bool> insert(const value_type& value);
137 #if CPPREFERENCE_STDVER <2011
138 iterator insert(iterator hint, const value_type& value);
139 #else
140 iterator insert(const_iterator hint, const value_type& value);
141 std::pair<iterator, bool> insert(value_type&& value);
142 iterator insert(const_iterator hint, value_type&& value);
143 void insert(std::initializer_list<value_type> ilist);
144 #endif
145 template<class InputIt>
146 void insert(InputIt first, InputIt last);
147
148 #if CPPREFERENCE_STDVER>= 2011
149 template<class... Args>
150 std::pair<iterator, bool> emplace(Args&& ... args);
151
152 template <class... Args>
153 iterator emplace_hint(const_iterator hint, Args&& ... args);
154 #endif
155
156 #if CPPREFERENCE_STDVER <2011
157 void erase(iterator pos);
158 void erase(iterator first, iterator last);
159 #else
160 iterator erase(const_iterator pos);
161 iterator erase(const_iterator first, const_iterator last);
162 #endif
163 size_type erase(const key_type& key);
164
165 void swap(set& other);
166
167 // lookup
168 size_type count(const Key& key) const;
169 template<class K>
170 size_type count(const K& x) const;
171
172 iterator find(const Key& key);
173 const_iterator find(const Key& key) const;
174
175 #if CPPREFERENCE_STDVER>= 2014
176 template<class K> iterator find(const K& x);
177 template<class K> const_iterator find(const K& x) const;
178 #endif
179
180 std::pair<iterator, iterator> equal_range(const Key& key);
181 std::pair<const_iterator, const_iterator> equal_range(const Key& key) const;
182
183 #if CPPREFERENCE_STDVER>= 2014
184 template<class K>
185 std::pair<iterator, iterator> equal_range(const K& x);
186
187 template<class K>
188 std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
189 #endif
190
191 iterator lower_bound(const Key& key);
192 const_iterator lower_bound(const Key& key) const;
193
194 #if CPPREFERENCE_STDVER>= 2014
195 template<class K>
196 iterator lower_bound(const K& x);
197
198 template<class K>
199 const_iterator lower_bound(const K& x) const;
200 #endif
201
202 iterator upper_bound(const Key& key);
203 const_iterator upper_bound(const Key& key) const;
204
205 #if CPPREFERENCE_STDVER>= 2014
206 template<class K>
207 iterator upper_bound(const K& x);
208
209 template<class K>
210 const_iterator upper_bound(const K& x) const;
211 #endif
212
213 // observers
214 key_compare key_comp() const;
215 value_compare value_comp() const;
216 };
217
218 template<class Key, class Compare, class Alloc>
219 bool operator==(const set<Key, Compare, Alloc>& lhs,
220 const set<Key, Compare, Alloc>& rhs);
221
222 template<class Key, class Compare, class Alloc>
223 bool operator!=(const set<Key, Compare, Alloc>& lhs,
224 const set<Key, Compare, Alloc>& rhs);
225
226 template<class Key, class Compare, class Alloc>
227 bool operator<(const set<Key, Compare, Alloc>& lhs,
228 const set<Key, Compare, Alloc>& rhs);
229
230 template<class Key, class Compare, class Alloc>
231 bool operator<=(const set<Key, Compare, Alloc>& lhs,
232 const set<Key, Compare, Alloc>& rhs);
233
234 template<class Key, class Compare, class Alloc>
235 bool operator>(const set<Key, Compare, Alloc>& lhs,
236 const set<Key, Compare, Alloc>& rhs);
237
238 template<class Key, class Compare, class Alloc>
239 bool operator>=(const set<Key, Compare, Alloc>& lhs,
240 const set<Key, Compare, Alloc>& rhs);
241
242 template<class Key, class Compare, class Alloc>
243 void swap(set<Key, Compare, Alloc>& lhs,
244 set<Key, Compare, Alloc>& rhs);
245
246 template <
247 class Key,
248 class Compare = std::less<Key>,
249 class Allocator = std::allocator<Key>
250 > class multiset {
251 public:
252 typedef Key key_type;
253 typedef Key value_type;
254 typedef Compare key_compare;
255 typedef Compare value_compare;
256 typedef Allocator allocator_type;
257 typedef size_t size_type; // actual type unspecified
258 typedef ptrdiff_t difference_type; // actual type not specified
259 #if CPPREFERENCE_SIMPLIFY_TYPEDEFS
260 typedef value_type& reference;
261 typedef const value_type& const_reference;
262 typedef value_type* pointer;
263 typedef const value_type* const_pointer;
264 #elif CPPREFERENCE_STDVER <2011
265 typedef typename Allocator::reference reference;
266 typedef typename Allocator::const_reference const_reference;
267 typedef typename Allocator::pointer pointer;
268 typedef typename Allocator::const_pointer const_pointer;
269 #else
270 typedef value_type& reference;
271 typedef const value_type& const_reference;
272 typedef typename std::allocator_traits<Allocator>::pointer pointer;
273 typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
274 #endif
275 typedef T* iterator; // actual type is unspecified
276 typedef const T* const_iterator; // actual type is unspecified
277 typedef std::reverse_iterator<iterator> reverse_iterator;
278 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
279
280 // constructor
281
282
283 #if CPPREFERENCE_STDVER <2014
284 explicit multiset(const Compare& comp = Compare(),
285 const Allocator& alloc = Allocator());
286 #else
287 multiset();
288 explicit multiset(const Compare& comp,
289 const Allocator& alloc = Allocator());
290 #endif
291
292 #if CPPREFERENCE_STDVER>= 2011
293 explicit multiset(const Allocator& alloc);
294 #endif
295
296 template<class InputIt>
297 multiset(InputIt first, InputIt last,
298 const Compare& comp = Compare(),
299 const Allocator& alloc = Allocator());
300
301 #if CPPREFERENCE_STDVER>= 2014
302 template<class InputIt>
303 multiset(InputIt first, InputIt last, const Allocator& alloc);
304 #endif
305
306 multiset(const multiset& other);
307
308 #if CPPREFERENCE_STDVER>= 2011
309 multiset(const multiset& other, const Allocator& alloc);
310 #endif
311
312 #if CPPREFERENCE_STDVER>= 2011
313 multiset(multiset&& other);
314 multiset(multiset&& other, const Allocator& alloc);
315
316 multiset(std::initializer_list<value_type> init,
317 const Compare& comp = Compare(),
318 const Allocator& alloc = Allocator());
319 #endif
320
321 #if CPPREFERENCE_STDVER>= 2014
322 multiset(std::initializer_list<value_type> init, const Allocator& alloc);
323 #endif
324
325 ~multiset();
326
327 multiset& operator=(const multiset& other);
328 #if CPPREFERENCE_STDVER>= 2011
329 multiset& operator=(multiset&& other);
330 multiset& operator=(initializer_list<value_type> ilist);
331 #endif
332
333 allocator_type get_allocator() const;
334
335 // iterators
336 iterator begin();
337 const_iterator begin() const;
338 iterator end();
339 const_iterator end() const;
340
341 reverse_iterator rbegin();
342 const_reverse_iterator rbegin() const;
343 reverse_iterator rend();
344 const_reverse_iterator rend() const;
345
346 #if CPPREFERENCE_STDVER>= 2011
347 const_iterator cbegin() const;
348 const_iterator cend() const;
349 const_reverse_iterator crbegin() const;
350 const_reverse_iterator crend() const;
351 #endif
352
353 // capacity
354 bool empty() const;
355 size_type size() const;
356 size_type max_size() const;
357
358 // modifiers
359 void clear();
360
361 std::pair<iterator, bool> insert(const value_type& value);
362 #if CPPREFERENCE_STDVER <2011
363 iterator insert(iterator hint, const value_type& value);
364 #else
365 iterator insert(const_iterator hint, const value_type& value);
366 std::pair<iterator, bool> insert(value_type&& value);
367 iterator insert(const_iterator hint, value_type&& value);
368 void insert(std::initializer_list<value_type> ilist);
369 #endif
370 template<class InputIt>
371 void insert(InputIt first, InputIt last);
372
373 #if CPPREFERENCE_STDVER>= 2011
374 template<class... Args>
375 std::pair<iterator, bool> emplace(Args&& ... args);
376
377 template <class... Args>
378 iterator emplace_hint(const_iterator hint, Args&& ... args);
379 #endif
380
381 #if CPPREFERENCE_STDVER <2011
382 void erase(iterator pos);
383 void erase(iterator first, iterator last);
384 #else
385 iterator erase(const_iterator pos);
386 iterator erase(const_iterator first, const_iterator last);
387 #endif
388 size_type erase(const key_type& key);
389
390 void swap(multiset& other);
391
392 // lookup
393 size_type count(const Key& key) const;
394 template<class K>
395 size_type count(const K& x) const;
396
397 iterator find(const Key& key);
398 const_iterator find(const Key& key) const;
399
400 #if CPPREFERENCE_STDVER>= 2014
401 template<class K> iterator find(const K& x);
402 template<class K> const_iterator find(const K& x) const;
403 #endif
404
405 std::pair<iterator, iterator> equal_range(const Key& key);
406 std::pair<const_iterator, const_iterator> equal_range(const Key& key) const;
407
408 #if CPPREFERENCE_STDVER>= 2014
409 template<class K>
410 std::pair<iterator, iterator> equal_range(const K& x);
411
412 template<class K>
413 std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
414 #endif
415
416 iterator lower_bound(const Key& key);
417 const_iterator lower_bound(const Key& key) const;
418
419 #if CPPREFERENCE_STDVER>= 2014
420 template<class K>
421 iterator lower_bound(const K& x);
422
423 template<class K>
424 const_iterator lower_bound(const K& x) const;
425 #endif
426
427 iterator upper_bound(const Key& key);
428 const_iterator upper_bound(const Key& key) const;
429
430 #if CPPREFERENCE_STDVER>= 2014
431 template<class K>
432 iterator upper_bound(const K& x);
433
434 template<class K>
435 const_iterator upper_bound(const K& x) const;
436 #endif
437
438 // observers
439 key_compare key_comp() const;
440 value_compare value_comp() const;
441 };
442
443 template<class Key, class Compare, class Alloc>
444 bool operator==(const multiset<Key, Compare, Alloc>& lhs,
445 const multiset<Key, Compare, Alloc>& rhs);
446
447 template<class Key, class Compare, class Alloc>
448 bool operator!=(const multiset<Key, Compare, Alloc>& lhs,
449 const multiset<Key, Compare, Alloc>& rhs);
450
451 template<class Key, class Compare, class Alloc>
452 bool operator<(const multiset<Key, Compare, Alloc>& lhs,
453 const multiset<Key, Compare, Alloc>& rhs);
454
455 template<class Key, class Compare, class Alloc>
456 bool operator<=(const multiset<Key, Compare, Alloc>& lhs,
457 const multiset<Key, Compare, Alloc>& rhs);
458
459 template<class Key, class Compare, class Alloc>
460 bool operator>(const multiset<Key, Compare, Alloc>& lhs,
461 const multiset<Key, Compare, Alloc>& rhs);
462
463 template<class Key, class Compare, class Alloc>
464 bool operator>=(const multiset<Key, Compare, Alloc>& lhs,
465 const multiset<Key, Compare, Alloc>& rhs);
466
467 template<class Key, class Compare, class Alloc>
468 void swap(multiset<Key, Compare, Alloc>& lhs,
469 multiset<Key, Compare, Alloc>& rhs);
470 } // namespace std
471
472 #endif // CPPREFERENCE_SET_H