YkESet 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +74 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE +21 -0
  5. data/README.md +68 -0
  6. data/Rakefile +13 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/docs/Yk/EMMap/Iterator.html +626 -0
  10. data/docs/Yk/EMMap.html +1504 -0
  11. data/docs/Yk/EMSet/Iterator.html +626 -0
  12. data/docs/Yk/EMSet.html +1472 -0
  13. data/docs/Yk/EMap/Iterator.html +626 -0
  14. data/docs/Yk/EMap.html +1730 -0
  15. data/docs/Yk/ESet/Iterator.html +626 -0
  16. data/docs/Yk/ESet.html +1472 -0
  17. data/docs/Yk.html +126 -0
  18. data/docs/_index.html +170 -0
  19. data/docs/class_list.html +51 -0
  20. data/docs/css/common.css +1 -0
  21. data/docs/css/full_list.css +58 -0
  22. data/docs/css/style.css +496 -0
  23. data/docs/file_list.html +51 -0
  24. data/docs/frames.html +17 -0
  25. data/docs/index.html +170 -0
  26. data/docs/js/app.js +314 -0
  27. data/docs/js/full_list.js +216 -0
  28. data/docs/js/jquery.js +4 -0
  29. data/docs/method_list.html +571 -0
  30. data/docs/top-level-namespace.html +110 -0
  31. data/eset.gemspec +29 -0
  32. data/ext/Yk/.ruby-version +1 -0
  33. data/ext/Yk/.yardoc/checksums +1 -0
  34. data/ext/Yk/.yardoc/complete +0 -0
  35. data/ext/Yk/.yardoc/object_types +0 -0
  36. data/ext/Yk/.yardoc/objects/root.dat +0 -0
  37. data/ext/Yk/.yardoc/proxy_types +0 -0
  38. data/ext/Yk/Makefile +267 -0
  39. data/ext/Yk/depend +2 -0
  40. data/ext/Yk/extconf.rb +7 -0
  41. data/ext/Yk/for_yard.rb +192 -0
  42. data/ext/Yk/for_yard_product.rb +397 -0
  43. data/ext/Yk/map_tz +78 -0
  44. data/ext/Yk/set_tz +77 -0
  45. data/ext/Yk/stl_map_tz.h +1026 -0
  46. data/ext/Yk/stl_multimap_tz.h +927 -0
  47. data/ext/Yk/stl_multiset_tz.h +805 -0
  48. data/ext/Yk/stl_set_tz.h +815 -0
  49. data/ext/Yk/stl_set_tz_ruby.cpp +575 -0
  50. data/ext/Yk/stl_tree_tz.h +1865 -0
  51. data/ext/Yk/test_set.rb +115 -0
  52. data/ext/Yk/tree_tz.cc +489 -0
  53. data/ext/Yk/tz_stl_auto.cpp +84 -0
  54. data/lib/eset/version.rb +3 -0
  55. data/lib/eset.rb +7 -0
  56. metadata +101 -0
@@ -0,0 +1,815 @@
1
+ // Set implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001-2013 Free Software Foundation, Inc.
4
+ //
5
+ // This file is part of the GNU ISO C++ Library. This library is free
6
+ // software; you can redistribute it and/or modify it under the
7
+ // terms of the GNU General Public License as published by the
8
+ // Free Software Foundation; either version 3, or (at your option)
9
+ // any later version.
10
+
11
+ // This library is distributed in the hope that it will be useful,
12
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ // GNU General Public License for more details.
15
+
16
+ // Under Section 7 of GPL version 3, you are granted additional
17
+ // permissions described in the GCC Runtime Library Exception, version
18
+ // 3.1, as published by the Free Software Foundation.
19
+
20
+ // You should have received a copy of the GNU General Public License and
21
+ // a copy of the GCC Runtime Library Exception along with this program;
22
+ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23
+ // <http://www.gnu.org/licenses/>.
24
+
25
+ /*
26
+ *
27
+ * Copyright (c) 1994
28
+ * Hewlett-Packard Company
29
+ *
30
+ * Permission to use, copy, modify, distribute and sell this software
31
+ * and its documentation for any purpose is hereby granted without fee,
32
+ * provided that the above copyright notice appear in all copies and
33
+ * that both that copyright notice and this permission notice appear
34
+ * in supporting documentation. Hewlett-Packard Company makes no
35
+ * representations about the suitability of this software for any
36
+ * purpose. It is provided "as is" without express or implied warranty.
37
+ *
38
+ *
39
+ * Copyright (c) 1996,1997
40
+ * Silicon Graphics Computer Systems, Inc.
41
+ *
42
+ * Permission to use, copy, modify, distribute and sell this software
43
+ * and its documentation for any purpose is hereby granted without fee,
44
+ * provided that the above copyright notice appear in all copies and
45
+ * that both that copyright notice and this permission notice appear
46
+ * in supporting documentation. Silicon Graphics makes no
47
+ * representations about the suitability of this software for any
48
+ * purpose. It is provided "as is" without express or implied warranty.
49
+ *
50
+ * Copyright (c) 2020
51
+ *
52
+ * Yougaein@github (Kokeji Yougain)
53
+ */
54
+
55
+ /** @file bits/stl_set.h
56
+ * This is an internal header file, included by other library headers.
57
+ * Do not attempt to use it directly. @headername{set}
58
+ */
59
+
60
+ #ifndef _STL_SET_TZ_H
61
+ #define _STL_SET_TZ_H 1
62
+
63
+ #include <bits/concept_check.h>
64
+ #if __cplusplus >= 201103L
65
+ #include <initializer_list>
66
+ #endif
67
+
68
+ namespace tz _GLIBCXX_VISIBILITY(default)
69
+ {
70
+ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
71
+
72
+ /**
73
+ * @brief A standard container made up of unique keys, which can be
74
+ * retrieved in logarithmic time.
75
+ *
76
+ * @ingroup associative_containers
77
+ *
78
+ * @tparam _Key Type of key objects.
79
+ * @tparam _Compare Comparison function object type, defaults to less<_Key>.
80
+ * @tparam _Alloc Allocator type, defaults to allocator<_Key>.
81
+ *
82
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
83
+ * <a href="tables.html#66">reversible container</a>, and an
84
+ * <a href="tables.html#69">associative container</a> (using unique keys).
85
+ *
86
+ * Sets support bidirectional iterators.
87
+ *
88
+ * The private tree data is declared exactly the same way for set and
89
+ * multiset; the distinction is made entirely in how the tree functions are
90
+ * called (*_unique versus *_equal, same as the standard).
91
+ */
92
+ template<typename _Key, typename _Compare = std::less<_Key>,
93
+ typename _Alloc = std::allocator<_Key> >
94
+ class set
95
+ {
96
+ // concept requirements
97
+ typedef typename _Alloc::value_type _Alloc_value_type;
98
+ __glibcxx_class_requires(_Key, _SGIAssignableConcept)
99
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
100
+ _BinaryFunctionConcept)
101
+ __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
102
+
103
+ public:
104
+ // typedefs:
105
+ //@{
106
+ /// Public typedefs.
107
+ typedef _Key key_type;
108
+ typedef _Key value_type;
109
+ typedef _Compare key_compare;
110
+ typedef _Compare value_compare;
111
+ typedef _Alloc allocator_type;
112
+ //@}
113
+
114
+ private:
115
+ typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
116
+
117
+ public:
118
+ typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
119
+ key_compare, _Key_alloc_type> _Rep_type;
120
+ _Rep_type _M_t; // Red-black tree representing set.
121
+
122
+ //@{
123
+ /// Iterator-related typedefs.
124
+ typedef typename _Key_alloc_type::pointer pointer;
125
+ typedef typename _Key_alloc_type::const_pointer const_pointer;
126
+ typedef typename _Key_alloc_type::reference reference;
127
+ typedef typename _Key_alloc_type::const_reference const_reference;
128
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
129
+ // DR 103. set::iterator is required to be modifiable,
130
+ // but this allows modification of keys.
131
+ typedef typename _Rep_type::const_iterator iterator;
132
+ typedef typename _Rep_type::const_iterator const_iterator;
133
+ typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
134
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
135
+ typedef typename _Rep_type::size_type size_type;
136
+ typedef typename _Rep_type::difference_type difference_type;
137
+ //@}
138
+
139
+ // allocation/deallocation
140
+ /**
141
+ * @brief Default constructor creates no elements.
142
+ */
143
+ set()
144
+ : _M_t() { }
145
+
146
+ /**
147
+ * @brief Creates a %set with no elements.
148
+ * @param __comp Comparator to use.
149
+ * @param __a An allocator object.
150
+ */
151
+ explicit
152
+ set(const _Compare& __comp,
153
+ const allocator_type& __a = allocator_type())
154
+ : _M_t(__comp, _Key_alloc_type(__a)) { }
155
+
156
+ /**
157
+ * @brief Builds a %set from a range.
158
+ * @param __first An input iterator.
159
+ * @param __last An input iterator.
160
+ *
161
+ * Create a %set consisting of copies of the elements from
162
+ * [__first,__last). This is linear in N if the range is
163
+ * already sorted, and NlogN otherwise (where N is
164
+ * distance(__first,__last)).
165
+ */
166
+ template<typename _InputIterator>
167
+ set(_InputIterator __first, _InputIterator __last)
168
+ : _M_t()
169
+ { _M_t._M_insert_unique(__first, __last); }
170
+
171
+ /**
172
+ * @brief Builds a %set from a range.
173
+ * @param __first An input iterator.
174
+ * @param __last An input iterator.
175
+ * @param __comp A comparison functor.
176
+ * @param __a An allocator object.
177
+ *
178
+ * Create a %set consisting of copies of the elements from
179
+ * [__first,__last). This is linear in N if the range is
180
+ * already sorted, and NlogN otherwise (where N is
181
+ * distance(__first,__last)).
182
+ */
183
+ template<typename _InputIterator>
184
+ set(_InputIterator __first, _InputIterator __last,
185
+ const _Compare& __comp,
186
+ const allocator_type& __a = allocator_type())
187
+ : _M_t(__comp, _Key_alloc_type(__a))
188
+ { _M_t._M_insert_unique(__first, __last); }
189
+
190
+ /**
191
+ * @brief %Set copy constructor.
192
+ * @param __x A %set of identical element and allocator types.
193
+ *
194
+ * The newly-created %set uses a copy of the allocation object used
195
+ * by @a __x.
196
+ */
197
+ set(const set& __x)
198
+ : _M_t(__x._M_t) { }
199
+
200
+ #if __cplusplus >= 201103L
201
+ /**
202
+ * @brief %Set move constructor
203
+ * @param __x A %set of identical element and allocator types.
204
+ *
205
+ * The newly-created %set contains the exact contents of @a x.
206
+ * The contents of @a x are a valid, but unspecified %set.
207
+ */
208
+ set(set&& __x)
209
+ noexcept(is_nothrow_copy_constructible<_Compare>::value)
210
+ : _M_t(std::move(__x._M_t)) { }
211
+
212
+ /**
213
+ * @brief Builds a %set from an initializer_list.
214
+ * @param __l An initializer_list.
215
+ * @param __comp A comparison functor.
216
+ * @param __a An allocator object.
217
+ *
218
+ * Create a %set consisting of copies of the elements in the list.
219
+ * This is linear in N if the list is already sorted, and NlogN
220
+ * otherwise (where N is @a __l.size()).
221
+ */
222
+ set(initializer_list<value_type> __l,
223
+ const _Compare& __comp = _Compare(),
224
+ const allocator_type& __a = allocator_type())
225
+ : _M_t(__comp, _Key_alloc_type(__a))
226
+ { _M_t._M_insert_unique(__l.begin(), __l.end()); }
227
+ #endif
228
+
229
+ /**
230
+ * @brief %Set assignment operator.
231
+ * @param __x A %set of identical element and allocator types.
232
+ *
233
+ * All the elements of @a __x are copied, but unlike the copy
234
+ * constructor, the allocator object is not copied.
235
+ */
236
+ set&
237
+ operator=(const set& __x)
238
+ {
239
+ _M_t = __x._M_t;
240
+ return *this;
241
+ }
242
+
243
+ #if __cplusplus >= 201103L
244
+ /**
245
+ * @brief %Set move assignment operator.
246
+ * @param __x A %set of identical element and allocator types.
247
+ *
248
+ * The contents of @a __x are moved into this %set (without copying).
249
+ * @a __x is a valid, but unspecified %set.
250
+ */
251
+ set&
252
+ operator=(set&& __x)
253
+ {
254
+ // NB: DR 1204.
255
+ // NB: DR 675.
256
+ this->clear();
257
+ this->swap(__x);
258
+ return *this;
259
+ }
260
+
261
+ /**
262
+ * @brief %Set list assignment operator.
263
+ * @param __l An initializer_list.
264
+ *
265
+ * This function fills a %set with copies of the elements in the
266
+ * initializer list @a __l.
267
+ *
268
+ * Note that the assignment completely changes the %set and
269
+ * that the resulting %set's size is the same as the number
270
+ * of elements assigned. Old data may be lost.
271
+ */
272
+ set&
273
+ operator=(initializer_list<value_type> __l)
274
+ {
275
+ this->clear();
276
+ this->insert(__l.begin(), __l.end());
277
+ return *this;
278
+ }
279
+ #endif
280
+
281
+ // accessors:
282
+
283
+ /// Returns the comparison object with which the %set was constructed.
284
+ key_compare
285
+ key_comp() const
286
+ { return _M_t.key_comp(); }
287
+ /// Returns the comparison object with which the %set was constructed.
288
+ value_compare
289
+ value_comp() const
290
+ { return _M_t.key_comp(); }
291
+ /// Returns the allocator object with which the %set was constructed.
292
+ allocator_type
293
+ get_allocator() const _GLIBCXX_NOEXCEPT
294
+ { return allocator_type(_M_t.get_allocator()); }
295
+
296
+ /**
297
+ * Returns a read-only (constant) iterator that points to the first
298
+ * element in the %set. Iteration is done in ascending order according
299
+ * to the keys.
300
+ */
301
+ iterator
302
+ begin() const _GLIBCXX_NOEXCEPT
303
+ { return _M_t.begin(); }
304
+
305
+ /**
306
+ * Returns a read-only (constant) iterator that points one past the last
307
+ * element in the %set. Iteration is done in ascending order according
308
+ * to the keys.
309
+ */
310
+ iterator
311
+ end() const _GLIBCXX_NOEXCEPT
312
+ { return _M_t.end(); }
313
+
314
+ /**
315
+ * Returns a read-only (constant) iterator that points to the last
316
+ * element in the %set. Iteration is done in descending order according
317
+ * to the keys.
318
+ */
319
+ reverse_iterator
320
+ rbegin() const _GLIBCXX_NOEXCEPT
321
+ { return _M_t.rbegin(); }
322
+
323
+ /**
324
+ * Returns a read-only (constant) reverse iterator that points to the
325
+ * last pair in the %set. Iteration is done in descending order
326
+ * according to the keys.
327
+ */
328
+ reverse_iterator
329
+ rend() const _GLIBCXX_NOEXCEPT
330
+ { return _M_t.rend(); }
331
+
332
+ #if __cplusplus >= 201103L
333
+ /**
334
+ * Returns a read-only (constant) iterator that points to the first
335
+ * element in the %set. Iteration is done in ascending order according
336
+ * to the keys.
337
+ */
338
+ iterator
339
+ cbegin() const noexcept
340
+ { return _M_t.begin(); }
341
+
342
+ /**
343
+ * Returns a read-only (constant) iterator that points one past the last
344
+ * element in the %set. Iteration is done in ascending order according
345
+ * to the keys.
346
+ */
347
+ iterator
348
+ cend() const noexcept
349
+ { return _M_t.end(); }
350
+
351
+ /**
352
+ * Returns a read-only (constant) iterator that points to the last
353
+ * element in the %set. Iteration is done in descending order according
354
+ * to the keys.
355
+ */
356
+ reverse_iterator
357
+ crbegin() const noexcept
358
+ { return _M_t.rbegin(); }
359
+
360
+ /**
361
+ * Returns a read-only (constant) reverse iterator that points to the
362
+ * last pair in the %set. Iteration is done in descending order
363
+ * according to the keys.
364
+ */
365
+ reverse_iterator
366
+ crend() const noexcept
367
+ { return _M_t.rend(); }
368
+ #endif
369
+
370
+ /// Returns true if the %set is empty.
371
+ bool
372
+ empty() const _GLIBCXX_NOEXCEPT
373
+ { return _M_t.empty(); }
374
+
375
+ /// Returns the size of the %set.
376
+ size_type
377
+ size() const _GLIBCXX_NOEXCEPT
378
+ { return _M_t.size(); }
379
+
380
+ /// Returns the maximum size of the %set.
381
+ size_type
382
+ max_size() const _GLIBCXX_NOEXCEPT
383
+ { return _M_t.max_size(); }
384
+
385
+ /**
386
+ * @brief Swaps data with another %set.
387
+ * @param __x A %set of the same element and allocator types.
388
+ *
389
+ * This exchanges the elements between two sets in constant
390
+ * time. (It is only swapping a pointer, an integer, and an
391
+ * instance of the @c Compare type (which itself is often
392
+ * stateless and empty), so it should be quite fast.) Note
393
+ * that the global std::swap() function is specialized such
394
+ * that std::swap(s1,s2) will feed to this function.
395
+ */
396
+ void
397
+ swap(set& __x)
398
+ { _M_t.swap(__x._M_t); }
399
+
400
+ // insert/erase
401
+ #if __cplusplus >= 201103L
402
+ /**
403
+ * @brief Attempts to build and insert an element into the %set.
404
+ * @param __args Arguments used to generate an element.
405
+ * @return A pair, of which the first element is an iterator that points
406
+ * to the possibly inserted element, and the second is a bool
407
+ * that is true if the element was actually inserted.
408
+ *
409
+ * This function attempts to build and insert an element into the %set.
410
+ * A %set relies on unique keys and thus an element is only inserted if
411
+ * it is not already present in the %set.
412
+ *
413
+ * Insertion requires logarithmic time.
414
+ */
415
+ template<typename... _Args>
416
+ std::pair<iterator, bool>
417
+ emplace(_Args&&... __args)
418
+ { return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
419
+
420
+ /**
421
+ * @brief Attempts to insert an element into the %set.
422
+ * @param __pos An iterator that serves as a hint as to where the
423
+ * element should be inserted.
424
+ * @param __args Arguments used to generate the element to be
425
+ * inserted.
426
+ * @return An iterator that points to the element with key equivalent to
427
+ * the one generated from @a __args (may or may not be the
428
+ * element itself).
429
+ *
430
+ * This function is not concerned about whether the insertion took place,
431
+ * and thus does not return a boolean like the single-argument emplace()
432
+ * does. Note that the first parameter is only a hint and can
433
+ * potentially improve the performance of the insertion process. A bad
434
+ * hint would cause no gains in efficiency.
435
+ *
436
+ * For more on @a hinting, see:
437
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
438
+ *
439
+ * Insertion requires logarithmic time (if the hint is not taken).
440
+ */
441
+ template<typename... _Args>
442
+ iterator
443
+ emplace_hint(const_iterator __pos, _Args&&... __args)
444
+ {
445
+ return _M_t._M_emplace_hint_unique(__pos,
446
+ std::forward<_Args>(__args)...);
447
+ }
448
+ #endif
449
+
450
+ /**
451
+ * @brief Attempts to insert an element into the %set.
452
+ * @param __x Element to be inserted.
453
+ * @return A pair, of which the first element is an iterator that points
454
+ * to the possibly inserted element, and the second is a bool
455
+ * that is true if the element was actually inserted.
456
+ *
457
+ * This function attempts to insert an element into the %set. A %set
458
+ * relies on unique keys and thus an element is only inserted if it is
459
+ * not already present in the %set.
460
+ *
461
+ * Insertion requires logarithmic time.
462
+ */
463
+ std::pair<iterator, bool>
464
+ insert(const value_type& __x)
465
+ {
466
+ std::pair<typename _Rep_type::iterator, bool> __p =
467
+ _M_t._M_insert_unique(__x);
468
+ return std::pair<iterator, bool>(__p.first, __p.second);
469
+ }
470
+
471
+ #if __cplusplus >= 201103L
472
+ std::pair<iterator, bool>
473
+ insert(value_type&& __x)
474
+ {
475
+ std::pair<typename _Rep_type::iterator, bool> __p =
476
+ _M_t._M_insert_unique(std::move(__x));
477
+ return std::pair<iterator, bool>(__p.first, __p.second);
478
+ }
479
+ #endif
480
+
481
+ /**
482
+ * @brief Attempts to insert an element into the %set.
483
+ * @param __position An iterator that serves as a hint as to where the
484
+ * element should be inserted.
485
+ * @param __x Element to be inserted.
486
+ * @return An iterator that points to the element with key of
487
+ * @a __x (may or may not be the element passed in).
488
+ *
489
+ * This function is not concerned about whether the insertion took place,
490
+ * and thus does not return a boolean like the single-argument insert()
491
+ * does. Note that the first parameter is only a hint and can
492
+ * potentially improve the performance of the insertion process. A bad
493
+ * hint would cause no gains in efficiency.
494
+ *
495
+ * For more on @a hinting, see:
496
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
497
+ *
498
+ * Insertion requires logarithmic time (if the hint is not taken).
499
+ */
500
+ iterator
501
+ insert(const_iterator __position, const value_type& __x)
502
+ { return _M_t._M_insert_unique_(__position, __x); }
503
+
504
+ #if __cplusplus >= 201103L
505
+ iterator
506
+ insert(const_iterator __position, value_type&& __x)
507
+ { return _M_t._M_insert_unique_(__position, std::move(__x)); }
508
+ #endif
509
+
510
+ /**
511
+ * @brief A template function that attempts to insert a range
512
+ * of elements.
513
+ * @param __first Iterator pointing to the start of the range to be
514
+ * inserted.
515
+ * @param __last Iterator pointing to the end of the range.
516
+ *
517
+ * Complexity similar to that of the range constructor.
518
+ */
519
+ template<typename _InputIterator>
520
+ void
521
+ insert(_InputIterator __first, _InputIterator __last)
522
+ { _M_t._M_insert_unique(__first, __last); }
523
+
524
+ #if __cplusplus >= 201103L
525
+ /**
526
+ * @brief Attempts to insert a list of elements into the %set.
527
+ * @param __l A std::initializer_list<value_type> of elements
528
+ * to be inserted.
529
+ *
530
+ * Complexity similar to that of the range constructor.
531
+ */
532
+ void
533
+ insert(initializer_list<value_type> __l)
534
+ { this->insert(__l.begin(), __l.end()); }
535
+ #endif
536
+
537
+ #if __cplusplus >= 201103L
538
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
539
+ // DR 130. Associative erase should return an iterator.
540
+ /**
541
+ * @brief Erases an element from a %set.
542
+ * @param __position An iterator pointing to the element to be erased.
543
+ * @return An iterator pointing to the element immediately following
544
+ * @a __position prior to the element being erased. If no such
545
+ * element exists, end() is returned.
546
+ *
547
+ * This function erases an element, pointed to by the given iterator,
548
+ * from a %set. Note that this function only erases the element, and
549
+ * that if the element is itself a pointer, the pointed-to memory is not
550
+ * touched in any way. Managing the pointer is the user's
551
+ * responsibility.
552
+ */
553
+ _GLIBCXX_ABI_TAG_CXX11
554
+ iterator
555
+ erase(const_iterator __position)
556
+ { return _M_t.erase(__position); }
557
+ #else
558
+ /**
559
+ * @brief Erases an element from a %set.
560
+ * @param position An iterator pointing to the element to be erased.
561
+ *
562
+ * This function erases an element, pointed to by the given iterator,
563
+ * from a %set. Note that this function only erases the element, and
564
+ * that if the element is itself a pointer, the pointed-to memory is not
565
+ * touched in any way. Managing the pointer is the user's
566
+ * responsibility.
567
+ */
568
+ void
569
+ erase(iterator __position)
570
+ { _M_t.erase(__position); }
571
+ #endif
572
+
573
+ /**
574
+ * @brief Erases elements according to the provided key.
575
+ * @param __x Key of element to be erased.
576
+ * @return The number of elements erased.
577
+ *
578
+ * This function erases all the elements located by the given key from
579
+ * a %set.
580
+ * Note that this function only erases the element, and that if
581
+ * the element is itself a pointer, the pointed-to memory is not touched
582
+ * in any way. Managing the pointer is the user's responsibility.
583
+ */
584
+ size_type
585
+ erase(const key_type& __x)
586
+ { return _M_t.erase(__x); }
587
+
588
+ #if __cplusplus >= 201103L
589
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
590
+ // DR 130. Associative erase should return an iterator.
591
+ /**
592
+ * @brief Erases a [__first,__last) range of elements from a %set.
593
+ * @param __first Iterator pointing to the start of the range to be
594
+ * erased.
595
+
596
+ * @param __last Iterator pointing to the end of the range to
597
+ * be erased.
598
+ * @return The iterator @a __last.
599
+ *
600
+ * This function erases a sequence of elements from a %set.
601
+ * Note that this function only erases the element, and that if
602
+ * the element is itself a pointer, the pointed-to memory is not touched
603
+ * in any way. Managing the pointer is the user's responsibility.
604
+ */
605
+ _GLIBCXX_ABI_TAG_CXX11
606
+ iterator
607
+ erase(const_iterator __first, const_iterator __last)
608
+ { return _M_t.erase(__first, __last); }
609
+ #else
610
+ /**
611
+ * @brief Erases a [first,last) range of elements from a %set.
612
+ * @param __first Iterator pointing to the start of the range to be
613
+ * erased.
614
+ * @param __last Iterator pointing to the end of the range to
615
+ * be erased.
616
+ *
617
+ * This function erases a sequence of elements from a %set.
618
+ * Note that this function only erases the element, and that if
619
+ * the element is itself a pointer, the pointed-to memory is not touched
620
+ * in any way. Managing the pointer is the user's responsibility.
621
+ */
622
+ void
623
+ erase(iterator __first, iterator __last)
624
+ { _M_t.erase(__first, __last); }
625
+ #endif
626
+
627
+ /**
628
+ * Erases all elements in a %set. Note that this function only erases
629
+ * the elements, and that if the elements themselves are pointers, the
630
+ * pointed-to memory is not touched in any way. Managing the pointer is
631
+ * the user's responsibility.
632
+ */
633
+ void
634
+ clear() _GLIBCXX_NOEXCEPT
635
+ { _M_t.clear(); }
636
+
637
+ // set operations:
638
+
639
+ /**
640
+ * @brief Finds the number of elements.
641
+ * @param __x Element to located.
642
+ * @return Number of elements with specified key.
643
+ *
644
+ * This function only makes sense for multisets; for set the result will
645
+ * either be 0 (not present) or 1 (present).
646
+ */
647
+ size_type
648
+ count(const key_type& __x) const
649
+ { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
650
+
651
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
652
+ // 214. set::find() missing const overload
653
+ //@{
654
+ /**
655
+ * @brief Tries to locate an element in a %set.
656
+ * @param __x Element to be located.
657
+ * @return Iterator pointing to sought-after element, or end() if not
658
+ * found.
659
+ *
660
+ * This function takes a key and tries to locate the element with which
661
+ * the key matches. If successful the function returns an iterator
662
+ * pointing to the sought after element. If unsuccessful it returns the
663
+ * past-the-end ( @c end() ) iterator.
664
+ */
665
+ iterator
666
+ find(const key_type& __x)
667
+ { return _M_t.find(__x); }
668
+
669
+ const_iterator
670
+ find(const key_type& __x) const
671
+ { return _M_t.find(__x); }
672
+ //@}
673
+
674
+ //@{
675
+ /**
676
+ * @brief Finds the beginning of a subsequence matching given key.
677
+ * @param __x Key to be located.
678
+ * @return Iterator pointing to first element equal to or greater
679
+ * than key, or end().
680
+ *
681
+ * This function returns the first element of a subsequence of elements
682
+ * that matches the given key. If unsuccessful it returns an iterator
683
+ * pointing to the first element that has a greater value than given key
684
+ * or end() if no such element exists.
685
+ */
686
+ iterator
687
+ lower_bound(const key_type& __x)
688
+ { return _M_t.lower_bound(__x); }
689
+
690
+ const_iterator
691
+ lower_bound(const key_type& __x) const
692
+ { return _M_t.lower_bound(__x); }
693
+ //@}
694
+
695
+ //@{
696
+ /**
697
+ * @brief Finds the end of a subsequence matching given key.
698
+ * @param __x Key to be located.
699
+ * @return Iterator pointing to the first element
700
+ * greater than key, or end().
701
+ */
702
+ iterator
703
+ upper_bound(const key_type& __x)
704
+ { return _M_t.upper_bound(__x); }
705
+
706
+ const_iterator
707
+ upper_bound(const key_type& __x) const
708
+ { return _M_t.upper_bound(__x); }
709
+ //@}
710
+
711
+ //@{
712
+ /**
713
+ * @brief Finds a subsequence matching given key.
714
+ * @param __x Key to be located.
715
+ * @return Pair of iterators that possibly points to the subsequence
716
+ * matching given key.
717
+ *
718
+ * This function is equivalent to
719
+ * @code
720
+ * std::make_pair(c.lower_bound(val),
721
+ * c.upper_bound(val))
722
+ * @endcode
723
+ * (but is faster than making the calls separately).
724
+ *
725
+ * This function probably only makes sense for multisets.
726
+ */
727
+ std::pair<iterator, iterator>
728
+ equal_range(const key_type& __x)
729
+ { return _M_t.equal_range(__x); }
730
+
731
+ std::pair<const_iterator, const_iterator>
732
+ equal_range(const key_type& __x) const
733
+ { return _M_t.equal_range(__x); }
734
+ //@}
735
+
736
+ template<typename _K1, typename _C1, typename _A1>
737
+ friend bool
738
+ operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
739
+
740
+ template<typename _K1, typename _C1, typename _A1>
741
+ friend bool
742
+ operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
743
+ };
744
+
745
+
746
+ /**
747
+ * @brief Set equality comparison.
748
+ * @param __x A %set.
749
+ * @param __y A %set of the same type as @a x.
750
+ * @return True iff the size and elements of the sets are equal.
751
+ *
752
+ * This is an equivalence relation. It is linear in the size of the sets.
753
+ * Sets are considered equivalent if their sizes are equal, and if
754
+ * corresponding elements compare equal.
755
+ */
756
+ template<typename _Key, typename _Compare, typename _Alloc>
757
+ inline bool
758
+ operator==(const set<_Key, _Compare, _Alloc>& __x,
759
+ const set<_Key, _Compare, _Alloc>& __y)
760
+ { return __x._M_t == __y._M_t; }
761
+
762
+ /**
763
+ * @brief Set ordering relation.
764
+ * @param __x A %set.
765
+ * @param __y A %set of the same type as @a x.
766
+ * @return True iff @a __x is lexicographically less than @a __y.
767
+ *
768
+ * This is a total ordering relation. It is linear in the size of the
769
+ * maps. The elements must be comparable with @c <.
770
+ *
771
+ * See std::lexicographical_compare() for how the determination is made.
772
+ */
773
+ template<typename _Key, typename _Compare, typename _Alloc>
774
+ inline bool
775
+ operator<(const set<_Key, _Compare, _Alloc>& __x,
776
+ const set<_Key, _Compare, _Alloc>& __y)
777
+ { return __x._M_t < __y._M_t; }
778
+
779
+ /// Returns !(x == y).
780
+ template<typename _Key, typename _Compare, typename _Alloc>
781
+ inline bool
782
+ operator!=(const set<_Key, _Compare, _Alloc>& __x,
783
+ const set<_Key, _Compare, _Alloc>& __y)
784
+ { return !(__x == __y); }
785
+
786
+ /// Returns y < x.
787
+ template<typename _Key, typename _Compare, typename _Alloc>
788
+ inline bool
789
+ operator>(const set<_Key, _Compare, _Alloc>& __x,
790
+ const set<_Key, _Compare, _Alloc>& __y)
791
+ { return __y < __x; }
792
+
793
+ /// Returns !(y < x)
794
+ template<typename _Key, typename _Compare, typename _Alloc>
795
+ inline bool
796
+ operator<=(const set<_Key, _Compare, _Alloc>& __x,
797
+ const set<_Key, _Compare, _Alloc>& __y)
798
+ { return !(__y < __x); }
799
+
800
+ /// Returns !(x < y)
801
+ template<typename _Key, typename _Compare, typename _Alloc>
802
+ inline bool
803
+ operator>=(const set<_Key, _Compare, _Alloc>& __x,
804
+ const set<_Key, _Compare, _Alloc>& __y)
805
+ { return !(__x < __y); }
806
+
807
+ /// See std::set::swap().
808
+ template<typename _Key, typename _Compare, typename _Alloc>
809
+ inline void
810
+ swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
811
+ { __x.swap(__y); }
812
+
813
+ _GLIBCXX_END_NAMESPACE_CONTAINER
814
+ } //namespace std
815
+ #endif /* _STL_SET_H */