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,927 @@
1
+ // Multimap 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_multimap.h
56
+ * This is an internal header file, included by other library headers.
57
+ * Do not attempt to use it directly. @headername{map}
58
+ */
59
+
60
+ #ifndef _STL_MULTIMAP_TZ_H
61
+ #define _STL_MULTIMAP_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 (key,value) pairs, which can be
74
+ * retrieved based on a key, in logarithmic time.
75
+ *
76
+ * @ingroup associative_containers
77
+ *
78
+ * @tparam _Key Type of key objects.
79
+ * @tparam _Tp Type of mapped objects.
80
+ * @tparam _Compare Comparison function object type, defaults to less<_Key>.
81
+ * @tparam _Alloc Allocator type, defaults to
82
+ * allocator<pair<const _Key, _Tp>.
83
+ *
84
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
85
+ * <a href="tables.html#66">reversible container</a>, and an
86
+ * <a href="tables.html#69">associative container</a> (using equivalent
87
+ * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
88
+ * is T, and the value_type is std::pair<const Key,T>.
89
+ *
90
+ * Multimaps support bidirectional iterators.
91
+ *
92
+ * The private tree data is declared exactly the same way for map and
93
+ * multimap; the distinction is made entirely in how the tree functions are
94
+ * called (*_unique versus *_equal, same as the standard).
95
+ */
96
+ template <typename _Key, typename _Tp,
97
+ typename _Compare = std::less<_Key>,
98
+ typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
99
+ class multimap
100
+ {
101
+ public:
102
+ typedef _Key key_type;
103
+ typedef _Tp mapped_type;
104
+ typedef std::pair<const _Key, _Tp> value_type;
105
+ typedef _Compare key_compare;
106
+ typedef _Alloc allocator_type;
107
+
108
+ private:
109
+ // concept requirements
110
+ typedef typename _Alloc::value_type _Alloc_value_type;
111
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
112
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
113
+ _BinaryFunctionConcept)
114
+ __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
115
+
116
+ public:
117
+ class value_compare
118
+ : public std::binary_function<value_type, value_type, bool>
119
+ {
120
+ friend class multimap<_Key, _Tp, _Compare, _Alloc>;
121
+ protected:
122
+ _Compare comp;
123
+
124
+ value_compare(_Compare __c)
125
+ : comp(__c) { }
126
+
127
+ public:
128
+ bool operator()(const value_type& __x, const value_type& __y) const
129
+ { return comp(__x.first, __y.first); }
130
+ };
131
+
132
+ private:
133
+ /// This turns a red-black tree into a [multi]map.
134
+ typedef typename _Alloc::template rebind<value_type>::other
135
+ _Pair_alloc_type;
136
+
137
+ typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
138
+ key_compare, _Pair_alloc_type> _Rep_type;
139
+ /// The actual tree structure.
140
+ public:
141
+ _Rep_type _M_t;
142
+
143
+ // many of these are specified differently in ISO, but the following are
144
+ // "functionally equivalent"
145
+ typedef typename _Pair_alloc_type::pointer pointer;
146
+ typedef typename _Pair_alloc_type::const_pointer const_pointer;
147
+ typedef typename _Pair_alloc_type::reference reference;
148
+ typedef typename _Pair_alloc_type::const_reference const_reference;
149
+ typedef typename _Rep_type::iterator iterator;
150
+ typedef typename _Rep_type::const_iterator const_iterator;
151
+ typedef typename _Rep_type::size_type size_type;
152
+ typedef typename _Rep_type::difference_type difference_type;
153
+ typedef typename _Rep_type::reverse_iterator reverse_iterator;
154
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
155
+
156
+ // [23.3.2] construct/copy/destroy
157
+ // (get_allocator() is also listed in this section)
158
+ /**
159
+ * @brief Default constructor creates no elements.
160
+ */
161
+ multimap()
162
+ : _M_t() { }
163
+
164
+ /**
165
+ * @brief Creates a %multimap with no elements.
166
+ * @param __comp A comparison object.
167
+ * @param __a An allocator object.
168
+ */
169
+ explicit
170
+ multimap(const _Compare& __comp,
171
+ const allocator_type& __a = allocator_type())
172
+ : _M_t(__comp, _Pair_alloc_type(__a)) { }
173
+
174
+ /**
175
+ * @brief %Multimap copy constructor.
176
+ * @param __x A %multimap of identical element and allocator types.
177
+ *
178
+ * The newly-created %multimap uses a copy of the allocation object
179
+ * used by @a __x.
180
+ */
181
+ multimap(const multimap& __x)
182
+ : _M_t(__x._M_t) { }
183
+
184
+ #if __cplusplus >= 201103L
185
+ /**
186
+ * @brief %Multimap move constructor.
187
+ * @param __x A %multimap of identical element and allocator types.
188
+ *
189
+ * The newly-created %multimap contains the exact contents of @a __x.
190
+ * The contents of @a __x are a valid, but unspecified %multimap.
191
+ */
192
+ multimap(multimap&& __x)
193
+ noexcept(is_nothrow_copy_constructible<_Compare>::value)
194
+ : _M_t(std::move(__x._M_t)) { }
195
+
196
+ /**
197
+ * @brief Builds a %multimap from an initializer_list.
198
+ * @param __l An initializer_list.
199
+ * @param __comp A comparison functor.
200
+ * @param __a An allocator object.
201
+ *
202
+ * Create a %multimap consisting of copies of the elements from
203
+ * the initializer_list. This is linear in N if the list is already
204
+ * sorted, and NlogN otherwise (where N is @a __l.size()).
205
+ */
206
+ multimap(initializer_list<value_type> __l,
207
+ const _Compare& __comp = _Compare(),
208
+ const allocator_type& __a = allocator_type())
209
+ : _M_t(__comp, _Pair_alloc_type(__a))
210
+ { _M_t._M_insert_equal(__l.begin(), __l.end()); }
211
+ #endif
212
+
213
+ /**
214
+ * @brief Builds a %multimap from a range.
215
+ * @param __first An input iterator.
216
+ * @param __last An input iterator.
217
+ *
218
+ * Create a %multimap consisting of copies of the elements from
219
+ * [__first,__last). This is linear in N if the range is already sorted,
220
+ * and NlogN otherwise (where N is distance(__first,__last)).
221
+ */
222
+ template<typename _InputIterator>
223
+ multimap(_InputIterator __first, _InputIterator __last)
224
+ : _M_t()
225
+ { _M_t._M_insert_equal(__first, __last); }
226
+
227
+ /**
228
+ * @brief Builds a %multimap from a range.
229
+ * @param __first An input iterator.
230
+ * @param __last An input iterator.
231
+ * @param __comp A comparison functor.
232
+ * @param __a An allocator object.
233
+ *
234
+ * Create a %multimap consisting of copies of the elements from
235
+ * [__first,__last). This is linear in N if the range is already sorted,
236
+ * and NlogN otherwise (where N is distance(__first,__last)).
237
+ */
238
+ template<typename _InputIterator>
239
+ multimap(_InputIterator __first, _InputIterator __last,
240
+ const _Compare& __comp,
241
+ const allocator_type& __a = allocator_type())
242
+ : _M_t(__comp, _Pair_alloc_type(__a))
243
+ { _M_t._M_insert_equal(__first, __last); }
244
+
245
+ // FIXME There is no dtor declared, but we should have something generated
246
+ // by Doxygen. I don't know what tags to add to this paragraph to make
247
+ // that happen:
248
+ /**
249
+ * The dtor only erases the elements, and note that if the elements
250
+ * themselves are pointers, the pointed-to memory is not touched in any
251
+ * way. Managing the pointer is the user's responsibility.
252
+ */
253
+
254
+ /**
255
+ * @brief %Multimap assignment operator.
256
+ * @param __x A %multimap of identical element and allocator types.
257
+ *
258
+ * All the elements of @a __x are copied, but unlike the copy
259
+ * constructor, the allocator object is not copied.
260
+ */
261
+ multimap&
262
+ operator=(const multimap& __x)
263
+ {
264
+ _M_t = __x._M_t;
265
+ return *this;
266
+ }
267
+
268
+ #if __cplusplus >= 201103L
269
+ /**
270
+ * @brief %Multimap move assignment operator.
271
+ * @param __x A %multimap of identical element and allocator types.
272
+ *
273
+ * The contents of @a __x are moved into this multimap (without copying).
274
+ * @a __x is a valid, but unspecified multimap.
275
+ */
276
+ multimap&
277
+ operator=(multimap&& __x)
278
+ {
279
+ // NB: DR 1204.
280
+ // NB: DR 675.
281
+ this->clear();
282
+ this->swap(__x);
283
+ return *this;
284
+ }
285
+
286
+ /**
287
+ * @brief %Multimap list assignment operator.
288
+ * @param __l An initializer_list.
289
+ *
290
+ * This function fills a %multimap with copies of the elements
291
+ * in the initializer list @a __l.
292
+ *
293
+ * Note that the assignment completely changes the %multimap and
294
+ * that the resulting %multimap's size is the same as the number
295
+ * of elements assigned. Old data may be lost.
296
+ */
297
+ multimap&
298
+ operator=(initializer_list<value_type> __l)
299
+ {
300
+ this->clear();
301
+ this->insert(__l.begin(), __l.end());
302
+ return *this;
303
+ }
304
+ #endif
305
+
306
+ /// Get a copy of the memory allocation object.
307
+ allocator_type
308
+ get_allocator() const _GLIBCXX_NOEXCEPT
309
+ { return allocator_type(_M_t.get_allocator()); }
310
+
311
+ // iterators
312
+ /**
313
+ * Returns a read/write iterator that points to the first pair in the
314
+ * %multimap. Iteration is done in ascending order according to the
315
+ * keys.
316
+ */
317
+ iterator
318
+ begin() _GLIBCXX_NOEXCEPT
319
+ { return _M_t.begin(); }
320
+
321
+ /**
322
+ * Returns a read-only (constant) iterator that points to the first pair
323
+ * in the %multimap. Iteration is done in ascending order according to
324
+ * the keys.
325
+ */
326
+ const_iterator
327
+ begin() const _GLIBCXX_NOEXCEPT
328
+ { return _M_t.begin(); }
329
+
330
+ /**
331
+ * Returns a read/write iterator that points one past the last pair in
332
+ * the %multimap. Iteration is done in ascending order according to the
333
+ * keys.
334
+ */
335
+ iterator
336
+ end() _GLIBCXX_NOEXCEPT
337
+ { return _M_t.end(); }
338
+
339
+ /**
340
+ * Returns a read-only (constant) iterator that points one past the last
341
+ * pair in the %multimap. Iteration is done in ascending order according
342
+ * to the keys.
343
+ */
344
+ const_iterator
345
+ end() const _GLIBCXX_NOEXCEPT
346
+ { return _M_t.end(); }
347
+
348
+ /**
349
+ * Returns a read/write reverse iterator that points to the last pair in
350
+ * the %multimap. Iteration is done in descending order according to the
351
+ * keys.
352
+ */
353
+ reverse_iterator
354
+ rbegin() _GLIBCXX_NOEXCEPT
355
+ { return _M_t.rbegin(); }
356
+
357
+ /**
358
+ * Returns a read-only (constant) reverse iterator that points to the
359
+ * last pair in the %multimap. Iteration is done in descending order
360
+ * according to the keys.
361
+ */
362
+ const_reverse_iterator
363
+ rbegin() const _GLIBCXX_NOEXCEPT
364
+ { return _M_t.rbegin(); }
365
+
366
+ /**
367
+ * Returns a read/write reverse iterator that points to one before the
368
+ * first pair in the %multimap. Iteration is done in descending order
369
+ * according to the keys.
370
+ */
371
+ reverse_iterator
372
+ rend() _GLIBCXX_NOEXCEPT
373
+ { return _M_t.rend(); }
374
+
375
+ /**
376
+ * Returns a read-only (constant) reverse iterator that points to one
377
+ * before the first pair in the %multimap. Iteration is done in
378
+ * descending order according to the keys.
379
+ */
380
+ const_reverse_iterator
381
+ rend() const _GLIBCXX_NOEXCEPT
382
+ { return _M_t.rend(); }
383
+
384
+ #if __cplusplus >= 201103L
385
+ /**
386
+ * Returns a read-only (constant) iterator that points to the first pair
387
+ * in the %multimap. Iteration is done in ascending order according to
388
+ * the keys.
389
+ */
390
+ const_iterator
391
+ cbegin() const noexcept
392
+ { return _M_t.begin(); }
393
+
394
+ /**
395
+ * Returns a read-only (constant) iterator that points one past the last
396
+ * pair in the %multimap. Iteration is done in ascending order according
397
+ * to the keys.
398
+ */
399
+ const_iterator
400
+ cend() const noexcept
401
+ { return _M_t.end(); }
402
+
403
+ /**
404
+ * Returns a read-only (constant) reverse iterator that points to the
405
+ * last pair in the %multimap. Iteration is done in descending order
406
+ * according to the keys.
407
+ */
408
+ const_reverse_iterator
409
+ crbegin() const noexcept
410
+ { return _M_t.rbegin(); }
411
+
412
+ /**
413
+ * Returns a read-only (constant) reverse iterator that points to one
414
+ * before the first pair in the %multimap. Iteration is done in
415
+ * descending order according to the keys.
416
+ */
417
+ const_reverse_iterator
418
+ crend() const noexcept
419
+ { return _M_t.rend(); }
420
+ #endif
421
+
422
+ // capacity
423
+ /** Returns true if the %multimap is empty. */
424
+ bool
425
+ empty() const _GLIBCXX_NOEXCEPT
426
+ { return _M_t.empty(); }
427
+
428
+ /** Returns the size of the %multimap. */
429
+ size_type
430
+ size() const _GLIBCXX_NOEXCEPT
431
+ { return _M_t.size(); }
432
+
433
+ /** Returns the maximum size of the %multimap. */
434
+ size_type
435
+ max_size() const _GLIBCXX_NOEXCEPT
436
+ { return _M_t.max_size(); }
437
+
438
+ // modifiers
439
+ #if __cplusplus >= 201103L
440
+ /**
441
+ * @brief Build and insert a std::pair into the %multimap.
442
+ *
443
+ * @param __args Arguments used to generate a new pair instance (see
444
+ * std::piecewise_contruct for passing arguments to each
445
+ * part of the pair constructor).
446
+ *
447
+ * @return An iterator that points to the inserted (key,value) pair.
448
+ *
449
+ * This function builds and inserts a (key, value) %pair into the
450
+ * %multimap.
451
+ * Contrary to a std::map the %multimap does not rely on unique keys and
452
+ * thus multiple pairs with the same key can be inserted.
453
+ *
454
+ * Insertion requires logarithmic time.
455
+ */
456
+ template<typename... _Args>
457
+ iterator
458
+ emplace(_Args&&... __args)
459
+ { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
460
+
461
+ /**
462
+ * @brief Builds and inserts a std::pair into the %multimap.
463
+ *
464
+ * @param __pos An iterator that serves as a hint as to where the pair
465
+ * should be inserted.
466
+ * @param __args Arguments used to generate a new pair instance (see
467
+ * std::piecewise_contruct for passing arguments to each
468
+ * part of the pair constructor).
469
+ * @return An iterator that points to the inserted (key,value) pair.
470
+ *
471
+ * This function inserts a (key, value) pair into the %multimap.
472
+ * Contrary to a std::map the %multimap does not rely on unique keys and
473
+ * thus multiple pairs with the same key can be inserted.
474
+ * Note that the first parameter is only a hint and can potentially
475
+ * improve the performance of the insertion process. A bad hint would
476
+ * cause no gains in efficiency.
477
+ *
478
+ * For more on @a hinting, see:
479
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
480
+ *
481
+ * Insertion requires logarithmic time (if the hint is not taken).
482
+ */
483
+ template<typename... _Args>
484
+ iterator
485
+ emplace_hint(const_iterator __pos, _Args&&... __args)
486
+ {
487
+ return _M_t._M_emplace_hint_equal(__pos,
488
+ std::forward<_Args>(__args)...);
489
+ }
490
+ #endif
491
+
492
+ /**
493
+ * @brief Inserts a std::pair into the %multimap.
494
+ * @param __x Pair to be inserted (see std::make_pair for easy creation
495
+ * of pairs).
496
+ * @return An iterator that points to the inserted (key,value) pair.
497
+ *
498
+ * This function inserts a (key, value) pair into the %multimap.
499
+ * Contrary to a std::map the %multimap does not rely on unique keys and
500
+ * thus multiple pairs with the same key can be inserted.
501
+ *
502
+ * Insertion requires logarithmic time.
503
+ */
504
+ iterator
505
+ insert(const value_type& __x)
506
+ { return _M_t._M_insert_equal(__x); }
507
+
508
+ #if __cplusplus >= 201103L
509
+ template<typename _Pair, typename = typename
510
+ std::enable_if<std::is_constructible<value_type,
511
+ _Pair&&>::value>::type>
512
+ iterator
513
+ insert(_Pair&& __x)
514
+ { return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
515
+ #endif
516
+
517
+ /**
518
+ * @brief Inserts a std::pair into the %multimap.
519
+ * @param __position An iterator that serves as a hint as to where the
520
+ * pair should be inserted.
521
+ * @param __x Pair to be inserted (see std::make_pair for easy creation
522
+ * of pairs).
523
+ * @return An iterator that points to the inserted (key,value) pair.
524
+ *
525
+ * This function inserts a (key, value) pair into the %multimap.
526
+ * Contrary to a std::map the %multimap does not rely on unique keys and
527
+ * thus multiple pairs with the same key can be inserted.
528
+ * Note that the first parameter is only a hint and can potentially
529
+ * improve the performance of the insertion process. A bad hint would
530
+ * cause no gains in efficiency.
531
+ *
532
+ * For more on @a hinting, see:
533
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
534
+ *
535
+ * Insertion requires logarithmic time (if the hint is not taken).
536
+ */
537
+ iterator
538
+ #if __cplusplus >= 201103L
539
+ insert(const_iterator __position, const value_type& __x)
540
+ #else
541
+ insert(iterator __position, const value_type& __x)
542
+ #endif
543
+ { return _M_t._M_insert_equal_(__position, __x); }
544
+
545
+ #if __cplusplus >= 201103L
546
+ template<typename _Pair, typename = typename
547
+ std::enable_if<std::is_constructible<value_type,
548
+ _Pair&&>::value>::type>
549
+ iterator
550
+ insert(const_iterator __position, _Pair&& __x)
551
+ { return _M_t._M_insert_equal_(__position,
552
+ std::forward<_Pair>(__x)); }
553
+ #endif
554
+
555
+ /**
556
+ * @brief A template function that attempts to insert a range
557
+ * of elements.
558
+ * @param __first Iterator pointing to the start of the range to be
559
+ * inserted.
560
+ * @param __last Iterator pointing to the end of the range.
561
+ *
562
+ * Complexity similar to that of the range constructor.
563
+ */
564
+ template<typename _InputIterator>
565
+ void
566
+ insert(_InputIterator __first, _InputIterator __last)
567
+ { _M_t._M_insert_equal(__first, __last); }
568
+
569
+ #if __cplusplus >= 201103L
570
+ /**
571
+ * @brief Attempts to insert a list of std::pairs into the %multimap.
572
+ * @param __l A std::initializer_list<value_type> of pairs to be
573
+ * inserted.
574
+ *
575
+ * Complexity similar to that of the range constructor.
576
+ */
577
+ void
578
+ insert(initializer_list<value_type> __l)
579
+ { this->insert(__l.begin(), __l.end()); }
580
+ #endif
581
+
582
+ #if __cplusplus >= 201103L
583
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
584
+ // DR 130. Associative erase should return an iterator.
585
+ /**
586
+ * @brief Erases an element from a %multimap.
587
+ * @param __position An iterator pointing to the element to be erased.
588
+ * @return An iterator pointing to the element immediately following
589
+ * @a position prior to the element being erased. If no such
590
+ * element exists, end() is returned.
591
+ *
592
+ * This function erases an element, pointed to by the given iterator,
593
+ * from a %multimap. Note that this function only erases the element,
594
+ * and that if the element is itself a pointer, the pointed-to memory is
595
+ * not touched in any way. Managing the pointer is the user's
596
+ * responsibility.
597
+ */
598
+ iterator
599
+ erase(const_iterator __position)
600
+ { return _M_t.erase(__position); }
601
+
602
+ // LWG 2059.
603
+ _GLIBCXX_ABI_TAG_CXX11
604
+ iterator
605
+ erase(iterator __position)
606
+ { return _M_t.erase(__position); }
607
+ #else
608
+ /**
609
+ * @brief Erases an element from a %multimap.
610
+ * @param __position An iterator pointing to the element to be erased.
611
+ *
612
+ * This function erases an element, pointed to by the given iterator,
613
+ * from a %multimap. Note that this function only erases the element,
614
+ * and that if the element is itself a pointer, the pointed-to memory is
615
+ * not touched in any way. Managing the pointer is the user's
616
+ * responsibility.
617
+ */
618
+ void
619
+ erase(iterator __position)
620
+ { _M_t.erase(__position); }
621
+ #endif
622
+
623
+ /**
624
+ * @brief Erases elements according to the provided key.
625
+ * @param __x Key of element to be erased.
626
+ * @return The number of elements erased.
627
+ *
628
+ * This function erases all elements located by the given key from a
629
+ * %multimap.
630
+ * Note that this function only erases the element, and that if
631
+ * the element is itself a pointer, the pointed-to memory is not touched
632
+ * in any way. Managing the pointer is the user's responsibility.
633
+ */
634
+ size_type
635
+ erase(const key_type& __x)
636
+ { return _M_t.erase(__x); }
637
+
638
+ #if __cplusplus >= 201103L
639
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
640
+ // DR 130. Associative erase should return an iterator.
641
+ /**
642
+ * @brief Erases a [first,last) range of elements from a %multimap.
643
+ * @param __first Iterator pointing to the start of the range to be
644
+ * erased.
645
+ * @param __last Iterator pointing to the end of the range to be
646
+ * erased .
647
+ * @return The iterator @a __last.
648
+ *
649
+ * This function erases a sequence of elements from a %multimap.
650
+ * Note that this function only erases the elements, and that if
651
+ * the elements themselves are pointers, the pointed-to memory is not
652
+ * touched in any way. Managing the pointer is the user's
653
+ * responsibility.
654
+ */
655
+ iterator
656
+ erase(const_iterator __first, const_iterator __last)
657
+ { return _M_t.erase(__first, __last); }
658
+ #else
659
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
660
+ // DR 130. Associative erase should return an iterator.
661
+ /**
662
+ * @brief Erases a [first,last) range of elements from a %multimap.
663
+ * @param __first Iterator pointing to the start of the range to be
664
+ * erased.
665
+ * @param __last Iterator pointing to the end of the range to
666
+ * be erased.
667
+ *
668
+ * This function erases a sequence of elements from a %multimap.
669
+ * Note that this function only erases the elements, and that if
670
+ * the elements themselves are pointers, the pointed-to memory is not
671
+ * touched in any way. Managing the pointer is the user's
672
+ * responsibility.
673
+ */
674
+ void
675
+ erase(iterator __first, iterator __last)
676
+ { _M_t.erase(__first, __last); }
677
+ #endif
678
+
679
+ /**
680
+ * @brief Swaps data with another %multimap.
681
+ * @param __x A %multimap of the same element and allocator types.
682
+ *
683
+ * This exchanges the elements between two multimaps in constant time.
684
+ * (It is only swapping a pointer, an integer, and an instance of
685
+ * the @c Compare type (which itself is often stateless and empty), so it
686
+ * should be quite fast.)
687
+ * Note that the global std::swap() function is specialized such that
688
+ * std::swap(m1,m2) will feed to this function.
689
+ */
690
+ void
691
+ swap(multimap& __x)
692
+ { _M_t.swap(__x._M_t); }
693
+
694
+ /**
695
+ * Erases all elements in a %multimap. Note that this function only
696
+ * erases the elements, and that if the elements themselves are pointers,
697
+ * the pointed-to memory is not touched in any way. Managing the pointer
698
+ * is the user's responsibility.
699
+ */
700
+ void
701
+ clear() _GLIBCXX_NOEXCEPT
702
+ { _M_t.clear(); }
703
+
704
+ // observers
705
+ /**
706
+ * Returns the key comparison object out of which the %multimap
707
+ * was constructed.
708
+ */
709
+ key_compare
710
+ key_comp() const
711
+ { return _M_t.key_comp(); }
712
+
713
+ /**
714
+ * Returns a value comparison object, built from the key comparison
715
+ * object out of which the %multimap was constructed.
716
+ */
717
+ value_compare
718
+ value_comp() const
719
+ { return value_compare(_M_t.key_comp()); }
720
+
721
+ // multimap operations
722
+ /**
723
+ * @brief Tries to locate an element in a %multimap.
724
+ * @param __x Key of (key, value) pair to be located.
725
+ * @return Iterator pointing to sought-after element,
726
+ * or end() if not found.
727
+ *
728
+ * This function takes a key and tries to locate the element with which
729
+ * the key matches. If successful the function returns an iterator
730
+ * pointing to the sought after %pair. If unsuccessful it returns the
731
+ * past-the-end ( @c end() ) iterator.
732
+ */
733
+ iterator
734
+ find(const key_type& __x)
735
+ { return _M_t.find(__x); }
736
+
737
+ /**
738
+ * @brief Tries to locate an element in a %multimap.
739
+ * @param __x Key of (key, value) pair to be located.
740
+ * @return Read-only (constant) iterator pointing to sought-after
741
+ * element, or end() if not found.
742
+ *
743
+ * This function takes a key and tries to locate the element with which
744
+ * the key matches. If successful the function returns a constant
745
+ * iterator pointing to the sought after %pair. If unsuccessful it
746
+ * returns the past-the-end ( @c end() ) iterator.
747
+ */
748
+ const_iterator
749
+ find(const key_type& __x) const
750
+ { return _M_t.find(__x); }
751
+
752
+ /**
753
+ * @brief Finds the number of elements with given key.
754
+ * @param __x Key of (key, value) pairs to be located.
755
+ * @return Number of elements with specified key.
756
+ */
757
+ size_type
758
+ count(const key_type& __x) const
759
+ { return _M_t.count(__x); }
760
+
761
+ /**
762
+ * @brief Finds the beginning of a subsequence matching given key.
763
+ * @param __x Key of (key, value) pair to be located.
764
+ * @return Iterator pointing to first element equal to or greater
765
+ * than key, or end().
766
+ *
767
+ * This function returns the first element of a subsequence of elements
768
+ * that matches the given key. If unsuccessful it returns an iterator
769
+ * pointing to the first element that has a greater value than given key
770
+ * or end() if no such element exists.
771
+ */
772
+ iterator
773
+ lower_bound(const key_type& __x)
774
+ { return _M_t.lower_bound(__x); }
775
+
776
+ /**
777
+ * @brief Finds the beginning of a subsequence matching given key.
778
+ * @param __x Key of (key, value) pair to be located.
779
+ * @return Read-only (constant) iterator pointing to first element
780
+ * equal to or greater than key, or end().
781
+ *
782
+ * This function returns the first element of a subsequence of
783
+ * elements that matches the given key. If unsuccessful the
784
+ * iterator will point to the next greatest element or, if no
785
+ * such greater element exists, to end().
786
+ */
787
+ const_iterator
788
+ lower_bound(const key_type& __x) const
789
+ { return _M_t.lower_bound(__x); }
790
+
791
+ /**
792
+ * @brief Finds the end of a subsequence matching given key.
793
+ * @param __x Key of (key, value) pair to be located.
794
+ * @return Iterator pointing to the first element
795
+ * greater than key, or end().
796
+ */
797
+ iterator
798
+ upper_bound(const key_type& __x)
799
+ { return _M_t.upper_bound(__x); }
800
+
801
+ /**
802
+ * @brief Finds the end of a subsequence matching given key.
803
+ * @param __x Key of (key, value) pair to be located.
804
+ * @return Read-only (constant) iterator pointing to first iterator
805
+ * greater than key, or end().
806
+ */
807
+ const_iterator
808
+ upper_bound(const key_type& __x) const
809
+ { return _M_t.upper_bound(__x); }
810
+
811
+ /**
812
+ * @brief Finds a subsequence matching given key.
813
+ * @param __x Key of (key, value) pairs to be located.
814
+ * @return Pair of iterators that possibly points to the subsequence
815
+ * matching given key.
816
+ *
817
+ * This function is equivalent to
818
+ * @code
819
+ * std::make_pair(c.lower_bound(val),
820
+ * c.upper_bound(val))
821
+ * @endcode
822
+ * (but is faster than making the calls separately).
823
+ */
824
+ std::pair<iterator, iterator>
825
+ equal_range(const key_type& __x)
826
+ { return _M_t.equal_range(__x); }
827
+
828
+ /**
829
+ * @brief Finds a subsequence matching given key.
830
+ * @param __x Key of (key, value) pairs to be located.
831
+ * @return Pair of read-only (constant) iterators that possibly points
832
+ * to the subsequence matching given key.
833
+ *
834
+ * This function is equivalent to
835
+ * @code
836
+ * std::make_pair(c.lower_bound(val),
837
+ * c.upper_bound(val))
838
+ * @endcode
839
+ * (but is faster than making the calls separately).
840
+ */
841
+ std::pair<const_iterator, const_iterator>
842
+ equal_range(const key_type& __x) const
843
+ { return _M_t.equal_range(__x); }
844
+
845
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
846
+ friend bool
847
+ operator==(const multimap<_K1, _T1, _C1, _A1>&,
848
+ const multimap<_K1, _T1, _C1, _A1>&);
849
+
850
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
851
+ friend bool
852
+ operator<(const multimap<_K1, _T1, _C1, _A1>&,
853
+ const multimap<_K1, _T1, _C1, _A1>&);
854
+ };
855
+
856
+ /**
857
+ * @brief Multimap equality comparison.
858
+ * @param __x A %multimap.
859
+ * @param __y A %multimap of the same type as @a __x.
860
+ * @return True iff the size and elements of the maps are equal.
861
+ *
862
+ * This is an equivalence relation. It is linear in the size of the
863
+ * multimaps. Multimaps are considered equivalent if their sizes are equal,
864
+ * and if corresponding elements compare equal.
865
+ */
866
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
867
+ inline bool
868
+ operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
869
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
870
+ { return __x._M_t == __y._M_t; }
871
+
872
+ /**
873
+ * @brief Multimap ordering relation.
874
+ * @param __x A %multimap.
875
+ * @param __y A %multimap of the same type as @a __x.
876
+ * @return True iff @a x is lexicographically less than @a y.
877
+ *
878
+ * This is a total ordering relation. It is linear in the size of the
879
+ * multimaps. The elements must be comparable with @c <.
880
+ *
881
+ * See std::lexicographical_compare() for how the determination is made.
882
+ */
883
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
884
+ inline bool
885
+ operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
886
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
887
+ { return __x._M_t < __y._M_t; }
888
+
889
+ /// Based on operator==
890
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
891
+ inline bool
892
+ operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
893
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
894
+ { return !(__x == __y); }
895
+
896
+ /// Based on operator<
897
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
898
+ inline bool
899
+ operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
900
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
901
+ { return __y < __x; }
902
+
903
+ /// Based on operator<
904
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
905
+ inline bool
906
+ operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
907
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
908
+ { return !(__y < __x); }
909
+
910
+ /// Based on operator<
911
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
912
+ inline bool
913
+ operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
914
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
915
+ { return !(__x < __y); }
916
+
917
+ /// See std::multimap::swap().
918
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
919
+ inline void
920
+ swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
921
+ multimap<_Key, _Tp, _Compare, _Alloc>& __y)
922
+ { __x.swap(__y); }
923
+
924
+ _GLIBCXX_END_NAMESPACE_CONTAINER
925
+ } // namespace std
926
+
927
+ #endif /* _STL_MULTIMAP_H */