1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | #ifndef _UNORDERED_SET_H |
31 | #define _UNORDERED_SET_H |
32 | |
33 | namespace std _GLIBCXX_VISIBILITY(default) |
34 | { |
35 | _GLIBCXX_BEGIN_NAMESPACE_CONTAINER |
36 | |
37 | |
38 | template<bool _Cache> |
39 | using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>; |
40 | |
41 | template<typename _Value, |
42 | typename _Hash = hash<_Value>, |
43 | typename _Pred = std::equal_to<_Value>, |
44 | typename _Alloc = std::allocator<_Value>, |
45 | typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>> |
46 | using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc, |
47 | __detail::_Identity, _Pred, _Hash, |
48 | __detail::_Mod_range_hashing, |
49 | __detail::_Default_ranged_hash, |
50 | __detail::_Prime_rehash_policy, _Tr>; |
51 | |
52 | |
53 | template<bool _Cache> |
54 | using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>; |
55 | |
56 | template<typename _Value, |
57 | typename _Hash = hash<_Value>, |
58 | typename _Pred = std::equal_to<_Value>, |
59 | typename _Alloc = std::allocator<_Value>, |
60 | typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>> |
61 | using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc, |
62 | __detail::_Identity, |
63 | _Pred, _Hash, |
64 | __detail::_Mod_range_hashing, |
65 | __detail::_Default_ranged_hash, |
66 | __detail::_Prime_rehash_policy, _Tr>; |
67 | |
68 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
69 | class unordered_multiset; |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | template<class _Value, |
93 | class _Hash = hash<_Value>, |
94 | class _Pred = std::equal_to<_Value>, |
95 | class _Alloc = std::allocator<_Value> > |
96 | class unordered_set |
97 | { |
98 | typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; |
99 | _Hashtable _M_h; |
100 | |
101 | public: |
102 | |
103 | |
104 | |
105 | typedef typename _Hashtable::key_type key_type; |
106 | typedef typename _Hashtable::value_type value_type; |
107 | typedef typename _Hashtable::hasher hasher; |
108 | typedef typename _Hashtable::key_equal key_equal; |
109 | typedef typename _Hashtable::allocator_type allocator_type; |
110 | |
111 | |
112 | |
113 | |
114 | typedef typename _Hashtable::pointer pointer; |
115 | typedef typename _Hashtable::const_pointer const_pointer; |
116 | typedef typename _Hashtable::reference reference; |
117 | typedef typename _Hashtable::const_reference const_reference; |
118 | typedef typename _Hashtable::iterator iterator; |
119 | typedef typename _Hashtable::const_iterator const_iterator; |
120 | typedef typename _Hashtable::local_iterator local_iterator; |
121 | typedef typename _Hashtable::const_local_iterator const_local_iterator; |
122 | typedef typename _Hashtable::size_type size_type; |
123 | typedef typename _Hashtable::difference_type difference_type; |
124 | |
125 | |
126 | #if __cplusplus > 201402L |
127 | using node_type = typename _Hashtable::node_type; |
128 | using insert_return_type = typename _Hashtable::insert_return_type; |
129 | #endif |
130 | |
131 | |
132 | |
133 | |
134 | unordered_set() = default; |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | explicit |
144 | unordered_set(size_type __n, |
145 | const hasher& __hf = hasher(), |
146 | const key_equal& __eql = key_equal(), |
147 | const allocator_type& __a = allocator_type()) |
148 | : _M_h(__n, __hf, __eql, __a) |
149 | { } |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | template<typename _InputIterator> |
165 | unordered_set(_InputIterator __first, _InputIterator __last, |
166 | size_type __n = 0, |
167 | const hasher& __hf = hasher(), |
168 | const key_equal& __eql = key_equal(), |
169 | const allocator_type& __a = allocator_type()) |
170 | : _M_h(__first, __last, __n, __hf, __eql, __a) |
171 | { } |
172 | |
173 | |
174 | unordered_set(const unordered_set&) = default; |
175 | |
176 | |
177 | unordered_set(unordered_set&&) = default; |
178 | |
179 | |
180 | |
181 | |
182 | |
183 | explicit |
184 | unordered_set(const allocator_type& __a) |
185 | : _M_h(__a) |
186 | { } |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | |
193 | unordered_set(const unordered_set& __uset, |
194 | const allocator_type& __a) |
195 | : _M_h(__uset._M_h, __a) |
196 | { } |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | |
203 | unordered_set(unordered_set&& __uset, |
204 | const allocator_type& __a) |
205 | : _M_h(std::move(__uset._M_h), __a) |
206 | { } |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | unordered_set(initializer_list<value_type> __l, |
220 | size_type __n = 0, |
221 | const hasher& __hf = hasher(), |
222 | const key_equal& __eql = key_equal(), |
223 | const allocator_type& __a = allocator_type()) |
224 | : _M_h(__l, __n, __hf, __eql, __a) |
225 | { } |
226 | |
227 | unordered_set(size_type __n, const allocator_type& __a) |
228 | : unordered_set(__n, hasher(), key_equal(), __a) |
229 | { } |
230 | |
231 | unordered_set(size_type __n, const hasher& __hf, |
232 | const allocator_type& __a) |
233 | : unordered_set(__n, __hf, key_equal(), __a) |
234 | { } |
235 | |
236 | template<typename _InputIterator> |
237 | unordered_set(_InputIterator __first, _InputIterator __last, |
238 | size_type __n, |
239 | const allocator_type& __a) |
240 | : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) |
241 | { } |
242 | |
243 | template<typename _InputIterator> |
244 | unordered_set(_InputIterator __first, _InputIterator __last, |
245 | size_type __n, const hasher& __hf, |
246 | const allocator_type& __a) |
247 | : unordered_set(__first, __last, __n, __hf, key_equal(), __a) |
248 | { } |
249 | |
250 | unordered_set(initializer_list<value_type> __l, |
251 | size_type __n, |
252 | const allocator_type& __a) |
253 | : unordered_set(__l, __n, hasher(), key_equal(), __a) |
254 | { } |
255 | |
256 | unordered_set(initializer_list<value_type> __l, |
257 | size_type __n, const hasher& __hf, |
258 | const allocator_type& __a) |
259 | : unordered_set(__l, __n, __hf, key_equal(), __a) |
260 | { } |
261 | |
262 | |
263 | unordered_set& |
264 | operator=(const unordered_set&) = default; |
265 | |
266 | |
267 | unordered_set& |
268 | operator=(unordered_set&&) = default; |
269 | |
270 | |
271 | |
272 | |
273 | |
274 | |
275 | |
276 | |
277 | |
278 | |
279 | |
280 | |
281 | unordered_set& |
282 | operator=(initializer_list<value_type> __l) |
283 | { |
284 | _M_h = __l; |
285 | return *this; |
286 | } |
287 | |
288 | |
289 | allocator_type |
290 | get_allocator() const noexcept |
291 | { return _M_h.get_allocator(); } |
292 | |
293 | |
294 | |
295 | |
296 | bool |
297 | empty() const noexcept |
298 | { return _M_h.empty(); } |
299 | |
300 | |
301 | size_type |
302 | size() const noexcept |
303 | { return _M_h.size(); } |
304 | |
305 | |
306 | size_type |
307 | max_size() const noexcept |
308 | { return _M_h.max_size(); } |
309 | |
310 | |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | iterator |
318 | begin() noexcept |
319 | { return _M_h.begin(); } |
320 | |
321 | const_iterator |
322 | begin() const noexcept |
323 | { return _M_h.begin(); } |
324 | |
325 | |
326 | |
327 | |
328 | |
329 | |
330 | |
331 | iterator |
332 | end() noexcept |
333 | { return _M_h.end(); } |
334 | |
335 | const_iterator |
336 | end() const noexcept |
337 | { return _M_h.end(); } |
338 | |
339 | |
340 | |
341 | |
342 | |
343 | |
344 | const_iterator |
345 | cbegin() const noexcept |
346 | { return _M_h.begin(); } |
347 | |
348 | |
349 | |
350 | |
351 | |
352 | const_iterator |
353 | cend() const noexcept |
354 | { return _M_h.end(); } |
355 | |
356 | |
357 | |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | |
366 | |
367 | |
368 | |
369 | |
370 | |
371 | |
372 | |
373 | template<typename... _Args> |
374 | std::pair<iterator, bool> |
375 | emplace(_Args&&... __args) |
376 | { return _M_h.emplace(std::forward<_Args>(__args)...); } |
377 | |
378 | |
379 | |
380 | |
381 | |
382 | |
383 | |
384 | |
385 | |
386 | |
387 | |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | template<typename... _Args> |
400 | iterator |
401 | emplace_hint(const_iterator __pos, _Args&&... __args) |
402 | { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } |
403 | |
404 | |
405 | |
406 | |
407 | |
408 | |
409 | |
410 | |
411 | |
412 | |
413 | |
414 | |
415 | |
416 | |
417 | |
418 | std::pair<iterator, bool> |
419 | insert(const value_type& __x) |
420 | { return _M_h.insert(__x); } |
421 | |
422 | std::pair<iterator, bool> |
423 | insert(value_type&& __x) |
424 | { return _M_h.insert(std::move(__x)); } |
425 | |
426 | |
427 | |
428 | |
429 | |
430 | |
431 | |
432 | |
433 | |
434 | |
435 | |
436 | |
437 | |
438 | |
439 | |
440 | |
441 | |
442 | |
443 | |
444 | |
445 | |
446 | |
447 | iterator |
448 | insert(const_iterator __hint, const value_type& __x) |
449 | { return _M_h.insert(__hint, __x); } |
450 | |
451 | iterator |
452 | insert(const_iterator __hint, value_type&& __x) |
453 | { return _M_h.insert(__hint, std::move(__x)); } |
454 | |
455 | |
456 | |
457 | |
458 | |
459 | |
460 | |
461 | |
462 | |
463 | |
464 | |
465 | template<typename _InputIterator> |
466 | void |
467 | insert(_InputIterator __first, _InputIterator __last) |
468 | { _M_h.insert(__first, __last); } |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | |
475 | |
476 | |
477 | void |
478 | insert(initializer_list<value_type> __l) |
479 | { _M_h.insert(__l); } |
480 | |
481 | #if __cplusplus > 201402L |
482 | |
483 | node_type |
484 | extract(const_iterator __pos) |
485 | { |
486 | __glibcxx_assert(__pos != end()); |
487 | return _M_h.extract(__pos); |
488 | } |
489 | |
490 | |
491 | node_type |
492 | extract(const key_type& __key) |
493 | { return _M_h.extract(__key); } |
494 | |
495 | |
496 | insert_return_type |
497 | insert(node_type&& __nh) |
498 | { return _M_h._M_reinsert_node(std::move(__nh)); } |
499 | |
500 | |
501 | iterator |
502 | insert(const_iterator, node_type&& __nh) |
503 | { return _M_h._M_reinsert_node(std::move(__nh)).position; } |
504 | #endif |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | |
518 | |
519 | |
520 | iterator |
521 | erase(const_iterator __position) |
522 | { return _M_h.erase(__position); } |
523 | |
524 | |
525 | iterator |
526 | erase(iterator __position) |
527 | { return _M_h.erase(__position); } |
528 | |
529 | |
530 | |
531 | |
532 | |
533 | |
534 | |
535 | |
536 | |
537 | |
538 | |
539 | |
540 | |
541 | |
542 | size_type |
543 | erase(const key_type& __x) |
544 | { return _M_h.erase(__x); } |
545 | |
546 | |
547 | |
548 | |
549 | |
550 | |
551 | |
552 | |
553 | |
554 | |
555 | |
556 | |
557 | |
558 | |
559 | |
560 | iterator |
561 | erase(const_iterator __first, const_iterator __last) |
562 | { return _M_h.erase(__first, __last); } |
563 | |
564 | |
565 | |
566 | |
567 | |
568 | |
569 | |
570 | void |
571 | clear() noexcept |
572 | { _M_h.clear(); } |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | |
580 | |
581 | |
582 | |
583 | void |
584 | swap(unordered_set& __x) |
585 | noexcept( noexcept(_M_h.swap(__x._M_h)) ) |
586 | { _M_h.swap(__x._M_h); } |
587 | |
588 | #if __cplusplus > 201402L |
589 | template<typename, typename, typename> |
590 | friend class _Hash_merge_helper; |
591 | |
592 | template<typename _H2, typename _P2> |
593 | void |
594 | merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) |
595 | { |
596 | using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>; |
597 | _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); |
598 | } |
599 | |
600 | template<typename _H2, typename _P2> |
601 | void |
602 | merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) |
603 | { merge(__source); } |
604 | |
605 | template<typename _H2, typename _P2> |
606 | void |
607 | merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) |
608 | { |
609 | using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>; |
610 | _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); |
611 | } |
612 | |
613 | template<typename _H2, typename _P2> |
614 | void |
615 | merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) |
616 | { merge(__source); } |
617 | #endif |
618 | |
619 | |
620 | |
621 | |
622 | |
623 | hasher |
624 | hash_function() const |
625 | { return _M_h.hash_function(); } |
626 | |
627 | |
628 | |
629 | key_equal |
630 | key_eq() const |
631 | { return _M_h.key_eq(); } |
632 | |
633 | |
634 | |
635 | |
636 | |
637 | |
638 | |
639 | |
640 | |
641 | |
642 | |
643 | |
644 | |
645 | |
646 | |
647 | iterator |
648 | find(const key_type& __x) |
649 | { return _M_h.find(__x); } |
650 | |
651 | const_iterator |
652 | find(const key_type& __x) const |
653 | { return _M_h.find(__x); } |
654 | |
655 | |
656 | |
657 | |
658 | |
659 | |
660 | |
661 | |
662 | |
663 | |
664 | |
665 | size_type |
666 | count(const key_type& __x) const |
667 | { return _M_h.count(__x); } |
668 | |
669 | |
670 | |
671 | |
672 | |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | std::pair<iterator, iterator> |
679 | equal_range(const key_type& __x) |
680 | { return _M_h.equal_range(__x); } |
681 | |
682 | std::pair<const_iterator, const_iterator> |
683 | equal_range(const key_type& __x) const |
684 | { return _M_h.equal_range(__x); } |
685 | |
686 | |
687 | |
688 | |
689 | |
690 | size_type |
691 | bucket_count() const noexcept |
692 | { return _M_h.bucket_count(); } |
693 | |
694 | |
695 | size_type |
696 | max_bucket_count() const noexcept |
697 | { return _M_h.max_bucket_count(); } |
698 | |
699 | |
700 | |
701 | |
702 | |
703 | |
704 | size_type |
705 | bucket_size(size_type __n) const |
706 | { return _M_h.bucket_size(__n); } |
707 | |
708 | |
709 | |
710 | |
711 | |
712 | |
713 | size_type |
714 | bucket(const key_type& __key) const |
715 | { return _M_h.bucket(__key); } |
716 | |
717 | |
718 | |
719 | |
720 | |
721 | |
722 | |
723 | |
724 | local_iterator |
725 | begin(size_type __n) |
726 | { return _M_h.begin(__n); } |
727 | |
728 | const_local_iterator |
729 | begin(size_type __n) const |
730 | { return _M_h.begin(__n); } |
731 | |
732 | const_local_iterator |
733 | cbegin(size_type __n) const |
734 | { return _M_h.cbegin(__n); } |
735 | |
736 | |
737 | |
738 | |
739 | |
740 | |
741 | |
742 | |
743 | |
744 | local_iterator |
745 | end(size_type __n) |
746 | { return _M_h.end(__n); } |
747 | |
748 | const_local_iterator |
749 | end(size_type __n) const |
750 | { return _M_h.end(__n); } |
751 | |
752 | const_local_iterator |
753 | cend(size_type __n) const |
754 | { return _M_h.cend(__n); } |
755 | |
756 | |
757 | |
758 | |
759 | |
760 | float |
761 | load_factor() const noexcept |
762 | { return _M_h.load_factor(); } |
763 | |
764 | |
765 | |
766 | float |
767 | max_load_factor() const noexcept |
768 | { return _M_h.max_load_factor(); } |
769 | |
770 | |
771 | |
772 | |
773 | |
774 | void |
775 | max_load_factor(float __z) |
776 | { _M_h.max_load_factor(__z); } |
777 | |
778 | |
779 | |
780 | |
781 | |
782 | |
783 | |
784 | |
785 | void |
786 | rehash(size_type __n) |
787 | { _M_h.rehash(__n); } |
788 | |
789 | |
790 | |
791 | |
792 | |
793 | |
794 | |
795 | |
796 | void |
797 | reserve(size_type __n) |
798 | { _M_h.reserve(__n); } |
799 | |
800 | template<typename _Value1, typename _Hash1, typename _Pred1, |
801 | typename _Alloc1> |
802 | friend bool |
803 | operator==(const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&, |
804 | const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&); |
805 | }; |
806 | |
807 | |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | |
814 | |
815 | |
816 | |
817 | |
818 | |
819 | |
820 | |
821 | |
822 | |
823 | |
824 | |
825 | |
826 | template<class _Value, |
827 | class _Hash = hash<_Value>, |
828 | class _Pred = std::equal_to<_Value>, |
829 | class _Alloc = std::allocator<_Value> > |
830 | class unordered_multiset |
831 | { |
832 | typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; |
833 | _Hashtable _M_h; |
834 | |
835 | public: |
836 | |
837 | |
838 | |
839 | typedef typename _Hashtable::key_type key_type; |
840 | typedef typename _Hashtable::value_type value_type; |
841 | typedef typename _Hashtable::hasher hasher; |
842 | typedef typename _Hashtable::key_equal key_equal; |
843 | typedef typename _Hashtable::allocator_type allocator_type; |
844 | |
845 | |
846 | |
847 | |
848 | typedef typename _Hashtable::pointer pointer; |
849 | typedef typename _Hashtable::const_pointer const_pointer; |
850 | typedef typename _Hashtable::reference reference; |
851 | typedef typename _Hashtable::const_reference const_reference; |
852 | typedef typename _Hashtable::iterator iterator; |
853 | typedef typename _Hashtable::const_iterator const_iterator; |
854 | typedef typename _Hashtable::local_iterator local_iterator; |
855 | typedef typename _Hashtable::const_local_iterator const_local_iterator; |
856 | typedef typename _Hashtable::size_type size_type; |
857 | typedef typename _Hashtable::difference_type difference_type; |
858 | |
859 | |
860 | #if __cplusplus > 201402L |
861 | using node_type = typename _Hashtable::node_type; |
862 | #endif |
863 | |
864 | |
865 | |
866 | |
867 | unordered_multiset() = default; |
868 | |
869 | |
870 | |
871 | |
872 | |
873 | |
874 | |
875 | |
876 | explicit |
877 | unordered_multiset(size_type __n, |
878 | const hasher& __hf = hasher(), |
879 | const key_equal& __eql = key_equal(), |
880 | const allocator_type& __a = allocator_type()) |
881 | : _M_h(__n, __hf, __eql, __a) |
882 | { } |
883 | |
884 | |
885 | |
886 | |
887 | |
888 | |
889 | |
890 | |
891 | |
892 | |
893 | |
894 | |
895 | |
896 | |
897 | template<typename _InputIterator> |
898 | unordered_multiset(_InputIterator __first, _InputIterator __last, |
899 | size_type __n = 0, |
900 | const hasher& __hf = hasher(), |
901 | const key_equal& __eql = key_equal(), |
902 | const allocator_type& __a = allocator_type()) |
903 | : _M_h(__first, __last, __n, __hf, __eql, __a) |
904 | { } |
905 | |
906 | |
907 | unordered_multiset(const unordered_multiset&) = default; |
908 | |
909 | |
910 | unordered_multiset(unordered_multiset&&) = default; |
911 | |
912 | |
913 | |
914 | |
915 | |
916 | |
917 | |
918 | |
919 | |
920 | |
921 | |
922 | |
923 | unordered_multiset(initializer_list<value_type> __l, |
924 | size_type __n = 0, |
925 | const hasher& __hf = hasher(), |
926 | const key_equal& __eql = key_equal(), |
927 | const allocator_type& __a = allocator_type()) |
928 | : _M_h(__l, __n, __hf, __eql, __a) |
929 | { } |
930 | |
931 | |
932 | unordered_multiset& |
933 | operator=(const unordered_multiset&) = default; |
934 | |
935 | |
936 | unordered_multiset& |
937 | operator=(unordered_multiset&&) = default; |
938 | |
939 | |
940 | |
941 | |
942 | |
943 | explicit |
944 | unordered_multiset(const allocator_type& __a) |
945 | : _M_h(__a) |
946 | { } |
947 | |
948 | |
949 | |
950 | |
951 | |
952 | |
953 | unordered_multiset(const unordered_multiset& __umset, |
954 | const allocator_type& __a) |
955 | : _M_h(__umset._M_h, __a) |
956 | { } |
957 | |
958 | |
959 | |
960 | |
961 | |
962 | |
963 | unordered_multiset(unordered_multiset&& __umset, |
964 | const allocator_type& __a) |
965 | : _M_h(std::move(__umset._M_h), __a) |
966 | { } |
967 | |
968 | unordered_multiset(size_type __n, const allocator_type& __a) |
969 | : unordered_multiset(__n, hasher(), key_equal(), __a) |
970 | { } |
971 | |
972 | unordered_multiset(size_type __n, const hasher& __hf, |
973 | const allocator_type& __a) |
974 | : unordered_multiset(__n, __hf, key_equal(), __a) |
975 | { } |
976 | |
977 | template<typename _InputIterator> |
978 | unordered_multiset(_InputIterator __first, _InputIterator __last, |
979 | size_type __n, |
980 | const allocator_type& __a) |
981 | : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) |
982 | { } |
983 | |
984 | template<typename _InputIterator> |
985 | unordered_multiset(_InputIterator __first, _InputIterator __last, |
986 | size_type __n, const hasher& __hf, |
987 | const allocator_type& __a) |
988 | : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) |
989 | { } |
990 | |
991 | unordered_multiset(initializer_list<value_type> __l, |
992 | size_type __n, |
993 | const allocator_type& __a) |
994 | : unordered_multiset(__l, __n, hasher(), key_equal(), __a) |
995 | { } |
996 | |
997 | unordered_multiset(initializer_list<value_type> __l, |
998 | size_type __n, const hasher& __hf, |
999 | const allocator_type& __a) |
1000 | : unordered_multiset(__l, __n, __hf, key_equal(), __a) |
1001 | { } |
1002 | |
1003 | |
1004 | |
1005 | |
1006 | |
1007 | |
1008 | |
1009 | |
1010 | |
1011 | |
1012 | |
1013 | |
1014 | unordered_multiset& |
1015 | operator=(initializer_list<value_type> __l) |
1016 | { |
1017 | _M_h = __l; |
1018 | return *this; |
1019 | } |
1020 | |
1021 | |
1022 | allocator_type |
1023 | get_allocator() const noexcept |
1024 | { return _M_h.get_allocator(); } |
1025 | |
1026 | |
1027 | |
1028 | |
1029 | bool |
1030 | empty() const noexcept |
1031 | { return _M_h.empty(); } |
1032 | |
1033 | |
1034 | size_type |
1035 | size() const noexcept |
1036 | { return _M_h.size(); } |
1037 | |
1038 | |
1039 | size_type |
1040 | max_size() const noexcept |
1041 | { return _M_h.max_size(); } |
1042 | |
1043 | |
1044 | |
1045 | |
1046 | |
1047 | |
1048 | |
1049 | |
1050 | iterator |
1051 | begin() noexcept |
1052 | { return _M_h.begin(); } |
1053 | |
1054 | const_iterator |
1055 | begin() const noexcept |
1056 | { return _M_h.begin(); } |
1057 | |
1058 | |
1059 | |
1060 | |
1061 | |
1062 | |
1063 | |
1064 | iterator |
1065 | end() noexcept |
1066 | { return _M_h.end(); } |
1067 | |
1068 | const_iterator |
1069 | end() const noexcept |
1070 | { return _M_h.end(); } |
1071 | |
1072 | |
1073 | |
1074 | |
1075 | |
1076 | |
1077 | const_iterator |
1078 | cbegin() const noexcept |
1079 | { return _M_h.begin(); } |
1080 | |
1081 | |
1082 | |
1083 | |
1084 | |
1085 | const_iterator |
1086 | cend() const noexcept |
1087 | { return _M_h.end(); } |
1088 | |
1089 | |
1090 | |
1091 | |
1092 | |
1093 | |
1094 | |
1095 | |
1096 | |
1097 | |
1098 | template<typename... _Args> |
1099 | iterator |
1100 | emplace(_Args&&... __args) |
1101 | { return _M_h.emplace(std::forward<_Args>(__args)...); } |
1102 | |
1103 | |
1104 | |
1105 | |
1106 | |
1107 | |
1108 | |
1109 | |
1110 | |
1111 | |
1112 | |
1113 | |
1114 | |
1115 | |
1116 | |
1117 | |
1118 | |
1119 | |
1120 | template<typename... _Args> |
1121 | iterator |
1122 | emplace_hint(const_iterator __pos, _Args&&... __args) |
1123 | { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } |
1124 | |
1125 | |
1126 | |
1127 | |
1128 | |
1129 | |
1130 | |
1131 | |
1132 | |
1133 | iterator |
1134 | insert(const value_type& __x) |
1135 | { return _M_h.insert(__x); } |
1136 | |
1137 | iterator |
1138 | insert(value_type&& __x) |
1139 | { return _M_h.insert(std::move(__x)); } |
1140 | |
1141 | |
1142 | |
1143 | |
1144 | |
1145 | |
1146 | |
1147 | |
1148 | |
1149 | |
1150 | |
1151 | |
1152 | |
1153 | |
1154 | |
1155 | |
1156 | |
1157 | |
1158 | |
1159 | iterator |
1160 | insert(const_iterator __hint, const value_type& __x) |
1161 | { return _M_h.insert(__hint, __x); } |
1162 | |
1163 | iterator |
1164 | insert(const_iterator __hint, value_type&& __x) |
1165 | { return _M_h.insert(__hint, std::move(__x)); } |
1166 | |
1167 | |
1168 | |
1169 | |
1170 | |
1171 | |
1172 | |
1173 | |
1174 | |
1175 | |
1176 | template<typename _InputIterator> |
1177 | void |
1178 | insert(_InputIterator __first, _InputIterator __last) |
1179 | { _M_h.insert(__first, __last); } |
1180 | |
1181 | |
1182 | |
1183 | |
1184 | |
1185 | |
1186 | |
1187 | |
1188 | void |
1189 | insert(initializer_list<value_type> __l) |
1190 | { _M_h.insert(__l); } |
1191 | |
1192 | #if __cplusplus > 201402L |
1193 | |
1194 | node_type |
1195 | extract(const_iterator __pos) |
1196 | { |
1197 | __glibcxx_assert(__pos != end()); |
1198 | return _M_h.extract(__pos); |
1199 | } |
1200 | |
1201 | |
1202 | node_type |
1203 | extract(const key_type& __key) |
1204 | { return _M_h.extract(__key); } |
1205 | |
1206 | |
1207 | iterator |
1208 | insert(node_type&& __nh) |
1209 | { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); } |
1210 | |
1211 | |
1212 | iterator |
1213 | insert(const_iterator __hint, node_type&& __nh) |
1214 | { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); } |
1215 | #endif |
1216 | |
1217 | |
1218 | |
1219 | |
1220 | |
1221 | |
1222 | |
1223 | |
1224 | |
1225 | |
1226 | |
1227 | |
1228 | |
1229 | |
1230 | |
1231 | |
1232 | iterator |
1233 | erase(const_iterator __position) |
1234 | { return _M_h.erase(__position); } |
1235 | |
1236 | |
1237 | iterator |
1238 | erase(iterator __position) |
1239 | { return _M_h.erase(__position); } |
1240 | |
1241 | |
1242 | |
1243 | |
1244 | |
1245 | |
1246 | |
1247 | |
1248 | |
1249 | |
1250 | |
1251 | |
1252 | |
1253 | |
1254 | |
1255 | size_type |
1256 | erase(const key_type& __x) |
1257 | { return _M_h.erase(__x); } |
1258 | |
1259 | |
1260 | |
1261 | |
1262 | |
1263 | |
1264 | |
1265 | |
1266 | |
1267 | |
1268 | |
1269 | |
1270 | |
1271 | |
1272 | |
1273 | |
1274 | |
1275 | iterator |
1276 | erase(const_iterator __first, const_iterator __last) |
1277 | { return _M_h.erase(__first, __last); } |
1278 | |
1279 | |
1280 | |
1281 | |
1282 | |
1283 | |
1284 | |
1285 | |
1286 | void |
1287 | clear() noexcept |
1288 | { _M_h.clear(); } |
1289 | |
1290 | |
1291 | |
1292 | |
1293 | |
1294 | |
1295 | |
1296 | |
1297 | |
1298 | |
1299 | void |
1300 | swap(unordered_multiset& __x) |
1301 | noexcept( noexcept(_M_h.swap(__x._M_h)) ) |
1302 | { _M_h.swap(__x._M_h); } |
1303 | |
1304 | #if __cplusplus > 201402L |
1305 | template<typename, typename, typename> |
1306 | friend class _Hash_merge_helper; |
1307 | |
1308 | template<typename _H2, typename _P2> |
1309 | void |
1310 | merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) |
1311 | { |
1312 | using _Merge_helper |
1313 | = _Hash_merge_helper<unordered_multiset, _H2, _P2>; |
1314 | _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); |
1315 | } |
1316 | |
1317 | template<typename _H2, typename _P2> |
1318 | void |
1319 | merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) |
1320 | { merge(__source); } |
1321 | |
1322 | template<typename _H2, typename _P2> |
1323 | void |
1324 | merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) |
1325 | { |
1326 | using _Merge_helper |
1327 | = _Hash_merge_helper<unordered_multiset, _H2, _P2>; |
1328 | _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); |
1329 | } |
1330 | |
1331 | template<typename _H2, typename _P2> |
1332 | void |
1333 | merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) |
1334 | { merge(__source); } |
1335 | #endif |
1336 | |
1337 | |
1338 | |
1339 | |
1340 | |
1341 | hasher |
1342 | hash_function() const |
1343 | { return _M_h.hash_function(); } |
1344 | |
1345 | |
1346 | |
1347 | key_equal |
1348 | key_eq() const |
1349 | { return _M_h.key_eq(); } |
1350 | |
1351 | |
1352 | |
1353 | |
1354 | |
1355 | |
1356 | |
1357 | |
1358 | |
1359 | |
1360 | |
1361 | |
1362 | |
1363 | |
1364 | |
1365 | iterator |
1366 | find(const key_type& __x) |
1367 | { return _M_h.find(__x); } |
1368 | |
1369 | const_iterator |
1370 | find(const key_type& __x) const |
1371 | { return _M_h.find(__x); } |
1372 | |
1373 | |
1374 | |
1375 | |
1376 | |
1377 | |
1378 | |
1379 | size_type |
1380 | count(const key_type& __x) const |
1381 | { return _M_h.count(__x); } |
1382 | |
1383 | |
1384 | |
1385 | |
1386 | |
1387 | |
1388 | |
1389 | |
1390 | std::pair<iterator, iterator> |
1391 | equal_range(const key_type& __x) |
1392 | { return _M_h.equal_range(__x); } |
1393 | |
1394 | std::pair<const_iterator, const_iterator> |
1395 | equal_range(const key_type& __x) const |
1396 | { return _M_h.equal_range(__x); } |
1397 | |
1398 | |
1399 | |
1400 | |
1401 | |
1402 | size_type |
1403 | bucket_count() const noexcept |
1404 | { return _M_h.bucket_count(); } |
1405 | |
1406 | |
1407 | size_type |
1408 | max_bucket_count() const noexcept |
1409 | { return _M_h.max_bucket_count(); } |
1410 | |
1411 | |
1412 | |
1413 | |
1414 | |
1415 | |
1416 | size_type |
1417 | bucket_size(size_type __n) const |
1418 | { return _M_h.bucket_size(__n); } |
1419 | |
1420 | |
1421 | |
1422 | |
1423 | |
1424 | |
1425 | size_type |
1426 | bucket(const key_type& __key) const |
1427 | { return _M_h.bucket(__key); } |
1428 | |
1429 | |
1430 | |
1431 | |
1432 | |
1433 | |
1434 | |
1435 | |
1436 | local_iterator |
1437 | begin(size_type __n) |
1438 | { return _M_h.begin(__n); } |
1439 | |
1440 | const_local_iterator |
1441 | begin(size_type __n) const |
1442 | { return _M_h.begin(__n); } |
1443 | |
1444 | const_local_iterator |
1445 | cbegin(size_type __n) const |
1446 | { return _M_h.cbegin(__n); } |
1447 | |
1448 | |
1449 | |
1450 | |
1451 | |
1452 | |
1453 | |
1454 | |
1455 | |
1456 | local_iterator |
1457 | end(size_type __n) |
1458 | { return _M_h.end(__n); } |
1459 | |
1460 | const_local_iterator |
1461 | end(size_type __n) const |
1462 | { return _M_h.end(__n); } |
1463 | |
1464 | const_local_iterator |
1465 | cend(size_type __n) const |
1466 | { return _M_h.cend(__n); } |
1467 | |
1468 | |
1469 | |
1470 | |
1471 | |
1472 | float |
1473 | load_factor() const noexcept |
1474 | { return _M_h.load_factor(); } |
1475 | |
1476 | |
1477 | |
1478 | float |
1479 | max_load_factor() const noexcept |
1480 | { return _M_h.max_load_factor(); } |
1481 | |
1482 | |
1483 | |
1484 | |
1485 | |
1486 | void |
1487 | max_load_factor(float __z) |
1488 | { _M_h.max_load_factor(__z); } |
1489 | |
1490 | |
1491 | |
1492 | |
1493 | |
1494 | |
1495 | |
1496 | |
1497 | void |
1498 | rehash(size_type __n) |
1499 | { _M_h.rehash(__n); } |
1500 | |
1501 | |
1502 | |
1503 | |
1504 | |
1505 | |
1506 | |
1507 | |
1508 | void |
1509 | reserve(size_type __n) |
1510 | { _M_h.reserve(__n); } |
1511 | |
1512 | template<typename _Value1, typename _Hash1, typename _Pred1, |
1513 | typename _Alloc1> |
1514 | friend bool |
1515 | operator==(const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&, |
1516 | const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&); |
1517 | }; |
1518 | |
1519 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1520 | inline void |
1521 | swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
1522 | unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) |
1523 | noexcept(noexcept(__x.swap(__y))) |
1524 | { __x.swap(__y); } |
1525 | |
1526 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1527 | inline void |
1528 | swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
1529 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) |
1530 | noexcept(noexcept(__x.swap(__y))) |
1531 | { __x.swap(__y); } |
1532 | |
1533 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1534 | inline bool |
1535 | operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
1536 | const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) |
1537 | { return __x._M_h._M_equal(__y._M_h); } |
1538 | |
1539 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1540 | inline bool |
1541 | operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
1542 | const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) |
1543 | { return !(__x == __y); } |
1544 | |
1545 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1546 | inline bool |
1547 | operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
1548 | const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) |
1549 | { return __x._M_h._M_equal(__y._M_h); } |
1550 | |
1551 | template<class _Value, class _Hash, class _Pred, class _Alloc> |
1552 | inline bool |
1553 | operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
1554 | const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) |
1555 | { return !(__x == __y); } |
1556 | |
1557 | _GLIBCXX_END_NAMESPACE_CONTAINER |
1558 | |
1559 | #if __cplusplus > 201402L |
1560 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
1561 | |
1562 | template<typename _Val, typename _Hash1, typename _Eq1, typename _Alloc, |
1563 | typename _Hash2, typename _Eq2> |
1564 | struct _Hash_merge_helper< |
1565 | _GLIBCXX_STD_C::unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2> |
1566 | { |
1567 | private: |
1568 | template<typename... _Tp> |
1569 | using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; |
1570 | template<typename... _Tp> |
1571 | using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; |
1572 | |
1573 | friend unordered_set<_Val, _Hash1, _Eq1, _Alloc>; |
1574 | |
1575 | static auto& |
1576 | _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) |
1577 | { return __set._M_h; } |
1578 | |
1579 | static auto& |
1580 | _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) |
1581 | { return __set._M_h; } |
1582 | }; |
1583 | |
1584 | |
1585 | template<typename _Val, typename _Hash1, typename _Eq1, typename _Alloc, |
1586 | typename _Hash2, typename _Eq2> |
1587 | struct _Hash_merge_helper< |
1588 | _GLIBCXX_STD_C::unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>, |
1589 | _Hash2, _Eq2> |
1590 | { |
1591 | private: |
1592 | template<typename... _Tp> |
1593 | using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; |
1594 | template<typename... _Tp> |
1595 | using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; |
1596 | |
1597 | friend unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>; |
1598 | |
1599 | static auto& |
1600 | _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) |
1601 | { return __set._M_h; } |
1602 | |
1603 | static auto& |
1604 | _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) |
1605 | { return __set._M_h; } |
1606 | }; |
1607 | _GLIBCXX_END_NAMESPACE_VERSION |
1608 | #endif |
1609 | |
1610 | } |
1611 | |
1612 | #endif |
1613 | |