YSTest: set.hpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

set.hpp
浏览该文件的文档.
1 /*
2 © 2016-2019 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_set_hpp_
29 #define YB_INC_ystdex_set_hpp_ 1
30
31 #include "functor.hpp" // for lref, std::move, less, std::allocator,
32 // std::piecewise_construct, enable_if_transparent,
33 // std::count, std::lower_bound, std::upper_bound, std::equal_range;
34 #include "iterator.hpp" // for transformed_iterator,
35 // iterator_transformation::second, ystdex::reverse_iterator,
36 // ystdex::make_transform, index_sequence, std::tuple, std::forward_as_tuple,
37 // std::get;
38 #include "map.hpp" // for "tree.h" (implying "range.hpp"), map,
39 // rebind_alloc_t, std::initializer_list, ystdex::search_map_by,
40 // ystdex::emplace_hint_in_place, ystdex::as_const;
41
42 namespace ystdex
43 {
44
45 // NOTE: This is always true now since %ystdex::map is used.
46 // XXX: G++ 5.2.0 rejects generic associative lookup in debug mode of %std::map.
47 // TODO: Find precise version supporting debug mode.
48 #if true \
49 || ((__cpp_lib_generic_associative_lookup >= 201304L \
50 || __cplusplus >= 201402L) && !(defined(__GLIBCXX__) \
51 && defined(_GLIBCXX_DEBUG)))
52 # define YB_Impl_Set_UseGenericLookup true
53 #else
54 # define YB_Impl_Set_UseGenericLookup false
55 #endif
56
58 namespace details
59 {
60
62 template<typename _tWrappedKey, typename _fComp,
63 bool = has_mem_is_transparent<_fComp>::value>
64 struct tcompare
65 {
66 _fComp comp{};
67
69 tcompare() = default;
70 tcompare(_fComp c)
71 : comp(std::move(c))
72 {}
73
74 bool
75 operator()(const _tWrappedKey& x, const _tWrappedKey& y) const
76 {
77 return bool(comp(x.get(), y.get()));
78 }
79 };
80
82 template<typename _tWrappedKey, typename _fComp>
83 struct tcompare<_tWrappedKey, _fComp, true>
84 : private tcompare<_tWrappedKey, _fComp, false>
85 {
86 private:
87 using base = tcompare<_tWrappedKey, _fComp, false>;
88
89 public:
90 using is_transparent = yimpl(void);
91
92 using base::comp;
93
94 #if YB_IMPL_CLANGPP
95 // NOTE: See https://llvm.org/bugs/show_bug.cgi?id=27504.
96 using tcompare<_tWrappedKey, _fComp, false>::tcompare;
97 #else
98 using base::tcompare;
99 #endif
100
101 using base::operator();
102 template<typename _tKey>
103 bool
104 operator()(const _tWrappedKey& x, const _tKey& y) const
105 {
106 return bool(comp(x.get(), y));
107 }
108 template<typename _tKey>
109 bool
110 operator()(const _tKey& x, const _tWrappedKey& y) const
111 {
112 return bool(comp(x, y.get()));
113 }
114 };
115
116
117 template<typename _type>
118 class wrapped_key
119 {
120 public:
121 using key_type = _type;
122 using wrapper = lref<const key_type>;
123
124 private:
125 mutable wrapper k;
126
127 public:
128 wrapped_key(const key_type& key)
129 : k(key)
130 {}
131
132 void
133 amend(const _type& key) const ynothrow
134 {
135 k = wrapper(key);
136 }
137
138 const _type&
139 get() const ynothrow
140 {
141 return k;
142 }
143 };
144
145 } // namespace details;
146
147
165 template<typename _type>
166 struct mapped_set_traits
167 {
169
170
174 template<typename _tKey, class _tCon>
175 static yconstfn _tKey&&
176 extend_key(_tKey&& k, _tCon&&) ynothrow
177 {
178 return yforward(k);
179 }
180
182
183 static yconstfn auto
184 get_value_key() ynothrow -> decltype(_type())
185 {
186 return _type();
187 }
188 template<typename _tKey, typename... _tParams>
189 static yconstfn const _tKey&
190 get_value_key(const _tKey& x, _tParams&&...) ynothrow
191 {
192 return x;
193 }
195
196
201 template<typename _tParam>
202 static yconstfn_relaxed void
203 restore_key(_type&, _tParam&&) ynothrow
204 {}
205
210 template<typename _tParam>
211 static yconstfn const _tParam&
212 set_value_move(const _tParam& x) ynothrow
213 {
214 return x;
215 }
216 };
217
218
237 template<typename _type, typename _fComp = less<_type>, class _tTraits
238 = mapped_set_traits<_type>, class _tAlloc = std::allocator<_type>>
239 class mapped_set
240 {
241 public:
242 using traits_type = _tTraits;
244
245 using key_type = _type;
246 using value_type = _type;
247 using key_compare = _fComp;
248 using value_compare = _fComp;
249 using allocator_type = _tAlloc;
250 using reference = value_type&;
251 using const_reference = const value_type&;
252
253 private:
254 using mapped_key_type = details::wrapped_key<_type>;
255 using mapped_key_compare = details::tcompare<mapped_key_type, _fComp>;
256 using umap_pair = std::pair<const mapped_key_type, value_type>;
257 using umap_type = map<mapped_key_type, value_type, mapped_key_compare,
258 rebind_alloc_t<_tAlloc, umap_pair>>;
259 // NOTE: Here %get_second cannot be used directory due to possible
260 // incomplete value type and requirement on conversion between
261 // 'const_iterator' and 'iterator'.
262 template<typename _tIter>
263 using wrap_iter
264 = transformed_iterator<_tIter, iterator_transformation::second<>>;
265
266 public:
267 using iterator = yimpl(wrap_iter<typename umap_type::iterator>);
268 using const_iterator = yimpl(wrap_iter<typename umap_type::const_iterator>);
269 using size_type = yimpl(typename umap_type::size_type);
270 using difference_type = yimpl(typename umap_type::difference_type);
271 using pointer = typename allocator_traits<_tAlloc>::pointer;
272 using const_pointer = typename allocator_traits<_tAlloc>::const_pointer;
273 using reverse_iterator = ystdex::reverse_iterator<iterator>;
274 using const_reverse_iterator = ystdex::reverse_iterator<const_iterator>;
275
276 private:
277 // XXX: It is undefined behavior when %value_type is incomplete if it is of
278 // an instance of %std::map, however some implementations actually support
279 // this.
280 umap_type m_map;
281
282 public:
283 mapped_set()
284 : mapped_set(_fComp())
285 {}
286 explicit
287 mapped_set(const _fComp& comp, const _tAlloc& a = _tAlloc())
288 : m_map(comp, a)
289 {}
290 template<typename _tIn>
291 mapped_set(_tIn first, _tIn last, const _fComp& comp = _fComp(),
292 const _tAlloc& a = _tAlloc())
293 : m_map(ystdex::make_transform(first, iter_trans<_tIn>),
294 ystdex::make_transform(last, iter_trans<_tIn>), comp, a)
295 {
296 amend_all();
297 }
298 mapped_set(const mapped_set& s)
299 : m_map(s.m_map)
300 {
301 amend_all();
302 }
303 mapped_set(mapped_set&& s)
304 // NOTE: ISO C++ allows the underlying associative container to throw on
305 // move.
306 yimpl(ynoexcept(is_nothrow_move_constructible<umap_type>()))
307 : m_map(std::move(s.m_map))
308 {
309 amend_all();
310 }
311 explicit
312 mapped_set(const _tAlloc& a)
313 : m_map(a)
314 {}
315 mapped_set(const mapped_set& s, const _tAlloc& a)
316 : m_map(s.m_map, a)
317 {
318 amend_all();
319 }
320 mapped_set(mapped_set&& s, const _tAlloc& a)
321 : m_map(std::move(s.m_map), a)
322 {
323 amend_all();
324 }
325 mapped_set(std::initializer_list<value_type> il,
326 const _fComp& comp = _fComp(), const _tAlloc& a = _tAlloc())
327 : mapped_set(il.begin(), il.end(), comp, a)
328 {}
329 template<typename _tIn>
330 mapped_set(_tIn first, _tIn last, const _tAlloc& a)
331 : mapped_set(first, last, _fComp(), a)
332 {}
333 mapped_set(std::initializer_list<value_type> il, const _tAlloc& a)
334 : mapped_set(il, _fComp(), a)
335 {}
336 ~mapped_set() yimpl(= default);
337
338 mapped_set&
339 operator=(const mapped_set& s)
340 {
341 // NOTE: The underlying implementation of %std::map may reuse node, e.g.
342 // in libstdc++. So it is preferred to directly move and then to fix
343 // references.
344 m_map = s.m_map;
345 amend_all();
346 return *this;
347 }
348 // NOTE: Since the resolution of LWG 2321 is respected in the underlying
349 // container, no %amend_all call is needed.
350 // XXX: The exception specification is changed. See the comment for the move
351 // assignment operator of %ystdex::map.
353 mapped_set&
354 operator=(mapped_set&&) yimpl(= default);
355 mapped_set&
356 operator=(std::initializer_list<value_type> il)
357 {
358 return *this = mapped_set(il);
359 }
360
361 YB_ATTR_nodiscard YB_PURE allocator_type
362 get_allocator() const ynothrow
363 {
364 return m_map.get_allocator();
365 }
366
367 YB_ATTR_nodiscard YB_PURE iterator
368 begin() ynothrow
369 {
370 return iterator(m_map.begin());
371 }
372 YB_ATTR_nodiscard YB_PURE const_iterator
373 begin() const ynothrow
374 {
375 return const_iterator(m_map.begin());
376 }
377
378 YB_ATTR_nodiscard YB_PURE iterator
379 end() ynothrow
380 {
381 return iterator(m_map.end());
382 }
383 YB_ATTR_nodiscard YB_PURE const_iterator
384 end() const ynothrow
385 {
386 return const_iterator(m_map.end());
387 }
388
389 YB_ATTR_nodiscard YB_PURE reverse_iterator
390 rbegin() ynothrow
391 {
392 return reverse_iterator(end());
393 }
394 YB_ATTR_nodiscard YB_PURE const_reverse_iterator
395 rbegin() const ynothrow
396 {
397 return const_reverse_iterator(end());
398 }
399
400 YB_ATTR_nodiscard YB_PURE reverse_iterator
401 rend() ynothrow
402 {
403 return reverse_iterator(begin());
404 }
405 YB_ATTR_nodiscard YB_PURE const_reverse_iterator
406 rend() const ynothrow
407 {
408 return const_reverse_iterator(begin());
409 }
410
411 YB_ATTR_nodiscard YB_PURE const_iterator
412 cbegin() const ynothrow
413 {
414 return const_iterator(m_map.cbegin());
415 }
416
417 YB_ATTR_nodiscard YB_PURE const_iterator
418 cend() const ynothrow
419 {
420 return const_iterator(m_map.cend());
421 }
422
423 YB_ATTR_nodiscard YB_PURE const_reverse_iterator
424 crbegin() const ynothrow
425 {
426 return const_reverse_iterator(end());
427 }
428
429 YB_ATTR_nodiscard YB_PURE const_reverse_iterator
430 crend() const ynothrow
431 {
432 return const_reverse_iterator(begin());
433 }
434
435 YB_ATTR_nodiscard YB_PURE bool
436 empty() const ynothrow
437 {
438 return m_map.empty();
439 }
440
441 YB_ATTR_nodiscard YB_PURE size_type
442 size() const ynothrow
443 {
444 return m_map.size();
445 }
446
447 YB_ATTR_nodiscard YB_PURE size_type
448 max_size() const ynothrow
449 {
450 return m_map.max_size();
451 }
452
464 template<typename... _tParams>
465 inline std::pair<iterator, bool>
466 emplace(_tParams&&... args)
467 {
468 return emplace_hint_impl(index_sequence<>(), std::tuple<>(),
469 yforward(args)...);
470 }
471
472 template<typename... _tParams>
473 inline iterator
474 emplace_hint(const_iterator position, _tParams&&... args)
475 {
476 return emplace_hint_impl(index_sequence<0>(),
477 std::forward_as_tuple(position.get()), yforward(args)...).first;
478 }
479
480 private:
482 template<size_t... _vSeq, typename... _tSeq, typename... _tParams>
483 std::pair<iterator, bool>
484 emplace_hint_impl(index_sequence<_vSeq...> seq, std::tuple<_tSeq...> pos,
485 _tParams&&... args)
486 {
487 auto&& k(traits_type::get_value_key(yforward(args)...));
488
489 return emplace_res_conv(emplace_search(
490 [&](typename umap_type::const_iterator i){
491 auto&& ek(traits_type::extend_key(std::move(k), *this));
492 // XXX: Blocked. 'yforward' cause G++ 5.3 crash: internal compiler
493 // error: Segmentation fault.
494 const auto j(ystdex::emplace_hint_in_place(m_map, i,
495 mapped_key_type(ystdex::as_const(ek)),
496 std::forward<_tParams>(args)...));
497
498 traits_type::restore_key(j->second, std::move(ek));
499 return j;
500 }, ystdex::as_const(k), seq, pos));
501 }
503
505 template<typename _func, typename _tKey, size_t... _vSeq, typename... _tSeq>
506 std::pair<typename umap_type::iterator, bool>
507 emplace_search(_func f, const _tKey& k, index_sequence<_vSeq...>,
508 std::tuple<_tSeq...> pos)
509 {
510 yunused(pos);
511 return ystdex::search_map_by([&](typename umap_type::const_iterator i){
512 const auto j(f(i));
513
514 amend_pair(*j);
515 return j;
516 }, m_map, std::get<_vSeq>(pos)..., k);
517 }
518
520 static std::pair<iterator, bool>
521 emplace_res_conv(const std::pair<typename umap_type::iterator, bool>& res)
522 {
523 return {iterator(res.first), res.second};
524 }
525
526 public:
527 std::pair<iterator, bool>
528 insert(const value_type& x)
529 {
530 return insert_unique(x);
531 }
532 std::pair<iterator, bool>
533 insert(value_type&& x)
534 {
535 return insert_unique(std::move(x));
536 }
537 iterator
538 insert(const_iterator position, const value_type& x)
539 {
540 return insert_unique_hint(position, x);
541 }
542 iterator
543 insert(const_iterator position, value_type&& x)
544 {
545 return insert_unique_hint(position, std::move(x));
546 }
547 template<typename _tIn>
548 void
549 insert(_tIn first, _tIn last)
550 {
551 m_map.insert(ystdex::make_transform(first, iter_trans<_tIn>),
552 ystdex::make_transform(last, iter_trans<_tIn>));
553 amend_all();
554 }
555 void
556 insert(std::initializer_list<value_type> il)
557 {
558 insert(il.begin(), il.end());
559 }
560
561 private:
563
564 static value_type
565 insert_forward(value_type& x)
566 {
567 return traits_type::set_value_move(x);
568 }
569 static const value_type&
570 insert_forward(const value_type& x)
571 {
572 return x;
573 }
574
575 template<typename _tParam>
576 inline std::pair<iterator, bool>
577 insert_unique(_tParam&& x)
578 {
579 return emplace_res_conv(insert_unique_impl(index_sequence<>(),
580 std::tuple<>(), yforward(x)));
581 }
582
583 template<typename _tParam>
584 inline iterator
585 insert_unique_hint(iterator position, _tParam&& x)
586 {
587 return iterator(insert_unique_impl(index_sequence<0>(),
588 std::forward_as_tuple(position.get()), yforward(x)).first);
589 }
590
591 template<size_t... _vSeq, typename... _tSeq, typename _tParam>
592 std::pair<typename umap_type::iterator, bool>
593 insert_unique_impl(index_sequence<_vSeq...> seq, std::tuple<_tSeq...> pos,
594 _tParam&& x)
595 {
596 return emplace_search([&](typename umap_type::const_iterator i){
597 // XXX: Result of %traits_type::set_value_move call need to be
598 // EmplaceConstructible into %mapped_type.
599 return ystdex::emplace_hint_in_place(m_map, i, mapped_key_type(x),
600 insert_forward(x));
601 }, x, seq, pos);
602 }
604
605 public:
606 iterator
607 erase(iterator position)
608 {
609 return iterator(m_map.erase(position.get()));
610 }
611 iterator
612 erase(const_iterator position)
613 {
614 return iterator(m_map.erase(position.get()));
615 }
616 size_type
617 erase(const key_type& x)
618 {
619 return m_map.erase(mapped_key_type(x));
620 }
621 iterator
622 erase(const_iterator first, const_iterator last)
623 {
624 return iterator(m_map.erase(first.get(), last.get()));
625 }
626
628 void
629 swap(mapped_set& s)
630 ynoexcept_spec(and_<typename allocator_traits<_tAlloc>::is_always_equal,
631 is_nothrow_move_assignable<_fComp>>::value)
632 {
633 m_map.swap(s.m_map);
634 }
635
636 void
637 clear() ynothrow
638 {
639 m_map.clear();
640 }
641
642 YB_ATTR_nodiscard YB_PURE key_compare
643 key_comp() const
644 {
645 return m_map.key_comp().comp;
646 }
647
648 YB_ATTR_nodiscard YB_PURE value_compare
649 value_comp() const
650 {
651 return m_map.key_comp().comp;
652 }
653
654 #define YB_Impl_Set_GenericLookupHead(_n, _r) \
655 template<typename _tTransKey, \
656 yimpl(typename = enable_if_transparent_t<_fComp, _tTransKey>)> \
657 YB_ATTR_nodiscard YB_PURE _r \
658 _n(const _tTransKey& x)
659
660 YB_ATTR_nodiscard YB_PURE iterator
661 find(const key_type& x)
662 {
663 return iterator(m_map.find(mapped_key_type(x)));
664 }
665 YB_ATTR_nodiscard YB_PURE const_iterator
666 find(const key_type& x) const
667 {
668 return const_iterator(m_map.find(mapped_key_type(x)));
669 }
671 YB_Impl_Set_GenericLookupHead(find, iterator)
672 {
673 #if YB_Impl_Set_UseGenericLookup
674 return iterator(m_map.find(x));
675 #else
676 const auto i(lower_bound(x));
677
678 return i != end() && !gcomp()(x, *i) ? i : end();
679 #endif
680 }
682 YB_Impl_Set_GenericLookupHead(find, const_iterator) const
683 {
684 #if YB_Impl_Set_UseGenericLookup
685 return const_iterator(m_map.find(x));
686 #else
687 const auto i(lower_bound(x));
688
689 return i != cend() && !gcomp()(x, *i) ? i : cend();
690 #endif
691 }
692
693 YB_ATTR_nodiscard YB_PURE size_type
694 count(const key_type& x) const
695 {
696 return m_map.count(mapped_key_type(x));
697 }
698 YB_Impl_Set_GenericLookupHead(count, size_type) const
699 {
700 #if YB_Impl_Set_UseGenericLookup
701 return m_map.count(x);
702 #else
703 const auto pr(equal_range(x));
704
705 return std::count(pr.first, pr.second, gcomp());
706 #endif
707 }
708
709 YB_ATTR_nodiscard YB_PURE iterator
710 lower_bound(const key_type& x)
711 {
712 return iterator(m_map.lower_bound(mapped_key_type(x)));
713 }
714 YB_ATTR_nodiscard YB_PURE const_iterator
715 lower_bound(const key_type& x) const
716 {
717 return const_iterator(m_map.lower_bound(mapped_key_type(x)));
718 }
720 YB_Impl_Set_GenericLookupHead(lower_bound, iterator)
721 {
722 #if YB_Impl_Set_UseGenericLookup
723 return iterator(m_map.lower_bound(x));
724 #else
725 return std::lower_bound(begin(), end(), x, gcomp());
726 #endif
727 }
729 YB_Impl_Set_GenericLookupHead(lower_bound, const_iterator) const
730 {
731 #if YB_Impl_Set_UseGenericLookup
732 return const_iterator(m_map.lower_bound(x));
733 #else
734 return std::lower_bound(cbegin(), cend(), x, gcomp());
735 #endif
736 }
737
738 YB_ATTR_nodiscard YB_PURE iterator
739 upper_bound(const key_type& x)
740 {
741 return iterator(m_map.upper_bound(mapped_key_type(x)));
742 }
743 YB_ATTR_nodiscard YB_PURE const_iterator
744 upper_bound(const key_type& x) const
745 {
746 return const_iterator(m_map.upper_bound(mapped_key_type(x)));
747 }
749 YB_Impl_Set_GenericLookupHead(upper_bound, iterator)
750 {
751 #if YB_Impl_Set_UseGenericLookup
752 return iterator(m_map.upper_bound(x));
753 #else
754 return std::upper_bound(begin(), end(), x, gcomp());
755 #endif
756 }
758 YB_Impl_Set_GenericLookupHead(upper_bound, const_iterator) const
759 {
760 #if YB_Impl_Set_UseGenericLookup
761 return const_iterator(m_map.upper_bound(x));
762 #else
763 return std::upper_bound(cbegin(), cend(), x, gcomp());
764 #endif
765 }
766
767 YB_ATTR_nodiscard YB_PURE std::pair<iterator, iterator>
768 equal_range(const key_type& x)
769 {
770 const auto pr(m_map.equal_range(mapped_key_type(x)));
771
772 return {iterator(pr.first), iterator(pr.second)};
773 }
774 YB_ATTR_nodiscard YB_PURE std::pair<const_iterator, const_iterator>
775 equal_range(const key_type& x) const
776 {
777 const auto pr(m_map.equal_range(mapped_key_type(x)));
778
779 return {const_iterator(pr.first), const_iterator(pr.second)};
780 }
782 YB_Impl_Set_GenericLookupHead(equal_range,
783 std::pair<iterator YPP_Comma iterator>)
784 {
785 #if YB_Impl_Set_UseGenericLookup
786 const auto pr(m_map.equal_range(x));
787
788 return {iterator(pr.first), iterator(pr.second)};
789 #else
790 return std::equal_range(begin(), end(), x, gcomp());
791 #endif
792 }
794 YB_Impl_Set_GenericLookupHead(equal_range,
795 std::pair<const_iterator YPP_Comma const_iterator>) const
796 {
797 #if YB_Impl_Set_UseGenericLookup
798 const auto pr(m_map.equal_range(x));
799
800 return {const_iterator(pr.first), const_iterator(pr.second)};
801 #else
802 return std::equal_range(cbegin(), cend(), x, gcomp());
803 #endif
804 }
805 #undef YB_Impl_Set_GenericLookupHead
806
807 private:
809 void
810 amend_all() const ynothrow
811 {
812 for(const auto& pr : m_map)
813 amend_pair(pr);
814 }
815
816 static void
817 amend_pair(const umap_pair& pr) ynothrow
818 {
819 pr.first.amend(pr.second);
820 }
821
822 #if !YB_Impl_Set_UseGenericLookup
823 mapped_key_compare
825 gcomp() const
826 {
827 return m_map.key_comp();
828 }
829 #endif
830
831 template<typename _tIter>
832 static umap_pair
833 iter_trans(const _tIter& i)
834 {
835 return {mapped_key_type(*i), *i};
836 }
838
840 friend void
841 swap(mapped_set& x, mapped_set& y) ynoexcept_spec(x.swap(y))
842 {
843 x.swap(y);
844 }
845 };
846
847 #undef YB_Impl_Set_UseGenericLookup
848
849 } // namespace ystdex;
850
851 #endif
852
ystdex::mapped_set::key_comp
key_compare key_comp() const
Definition: set.hpp:643
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::reference
value_type & reference
Definition: set.hpp:250
ystdex::mapped_set::cbegin
const_iterator cbegin() const
Definition: set.hpp:412
ystdex::mapped_set
允许指定不同于值类型的键的集合。
Definition: set.hpp:240
ystdex::mapped_set::crbegin
const_reverse_iterator crbegin() const
Definition: set.hpp:424
ystdex::mapped_set_traits::set_value_move
static const _tParam & set_value_move(const _tParam &x)
转移集合元素。
Definition: set.hpp:212
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
ystdex::mapped_set::m_map
umap_type m_map
Definition: set.hpp:280
ystdex::mapped_set::rend
const_reverse_iterator rend() const
Definition: set.hpp:406
ystdex::map::find
iterator find(const key_type &x)
Definition: map.hpp:619
CHRLib::c
c
Definition: CharacterProcessing.h:84
ystdex::lref< const key_type >
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
ystdex::mapped_set::const_reverse_iterator
ystdex::reverse_iterator< const_iterator > const_reverse_iterator
Definition: set.hpp:274
ystdex::mapped_set::insert
void insert(std::initializer_list< value_type > il)
Definition: set.hpp:556
ystdex::mapped_set::insert_forward
static const value_type & insert_forward(const value_type &x)
Definition: set.hpp:570
ystdex::cpp2017::allocator_traits
Definition: allocator.hpp:384
ystdex::cpp2017::reverse_iterator
Definition: range.hpp:116
YSLib::IO::_tTraits
const string &path const String &path class class _tTraits
Definition: YSLib/Service/FileSystem.h:582
ystdex::mapped_set::insert
std::pair< iterator, bool > insert(const value_type &x)
Definition: set.hpp:528
ystdex::emplace_hint_in_place
auto emplace_hint_in_place(_tAssocCon &con, typename _tAssocCon::const_iterator hint, _tKey &&k, _tParams &&... args) -> typename _tAssocCon::iterator
带有提示的原地插入构造。
Definition: container.hpp:870
ystdex::mapped_set::insert
iterator insert(const_iterator position, const value_type &x)
Definition: set.hpp:538
ystdex::mapped_set::mapped_set
mapped_set(std::initializer_list< value_type > il, const _tAlloc &a)
Definition: set.hpp:333
ystdex::map< mapped_key_type, value_type, mapped_key_compare, rebind_alloc_t< allocator_type, umap_pair > >::difference_type
typename rep_type::difference_type difference_type
Definition: map.hpp:124
ystdex::map::begin
iterator begin()
Definition: map.hpp:227
map.hpp
映射容器。
ystdex::cpp2014::less
小于关系仿函数。
Definition: functor.hpp:398
ystdex::mapped_set::mapped_set
mapped_set(const _tAlloc &a)
Definition: set.hpp:312
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:1181
ystdex::details::tcompare< _tWrappedKey, _fComp, true >::operator()
bool operator()(const _tKey &x, const _tWrappedKey &y) const
Definition: set.hpp:110
ystdex::map::erase
iterator erase(iterator position)
Definition: map.hpp:563
ystdex::mapped_set::size
size_type size() const
Definition: set.hpp:442
ystdex::mapped_set::count
size_type count(const key_type &x) const
Definition: set.hpp:694
ystdex::map< mapped_key_type, value_type, mapped_key_compare, rebind_alloc_t< allocator_type, umap_pair > >::size_type
typename rep_type::size_type size_type
Definition: map.hpp:122
ystdex::map::get_allocator
allocator_type get_allocator() const
Definition: map.hpp:221
ystdex::details::tcompare::tcompare
tcompare()=default
ystdex::map::swap
void swap(map &x)
Definition: map.hpp:588
CHRLib::f
f(d, s)
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:1097
ystdex::mapped_set::mapped_set
mapped_set(const mapped_set &s)
Definition: set.hpp:298
ystdex::mapped_set::clear
void clear()
Definition: set.hpp:637
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::value_type
ValueNode value_type
Definition: set.hpp:246
YB_Impl_Set_GenericLookupHead
#define YB_Impl_Set_GenericLookupHead(_n, _r)
Definition: set.hpp:654
ystdex::mapped_set::mapped_set
mapped_set(const _fComp &comp, const _tAlloc &a=_tAlloc())
Definition: set.hpp:287
ystdex::map< mapped_key_type, value_type, mapped_key_compare, rebind_alloc_t< allocator_type, umap_pair > >
ystdex::mapped_set::empty
bool empty() const
Definition: set.hpp:436
ystdex::details::tcompare::comp
_fComp comp
Definition: set.hpp:66
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
ystdex::mapped_set::insert
iterator insert(const_iterator position, value_type &&x)
Definition: set.hpp:543
ystdex::mapped_set::reverse_iterator
ystdex::reverse_iterator< iterator > reverse_iterator
Definition: set.hpp:273
ystdex::details::wrapped_key::amend
void amend(const _type &key) const
Definition: set.hpp:133
ystdex::mapped_set::gcomp
mapped_key_compare gcomp() const
Definition: set.hpp:825
ystdex::mapped_set::mapped_set
mapped_set(const mapped_set &s, const _tAlloc &a)
Definition: set.hpp:315
ystdex::details::wrapped_key::wrapper
lref< const key_type > wrapper
Definition: set.hpp:122
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::traits_type
MappedSetTraits traits_type
Definition: set.hpp:242
ystdex::mapped_set::find
const_iterator find(const key_type &x) const
Definition: set.hpp:666
ystdex::map::clear
void clear()
Definition: map.hpp:601
ystdex::mapped_set_traits
映射值集合特征。
Definition: set.hpp:167
ystdex::details::wrapped_key::get
const _type & get() const
Definition: set.hpp:139
ystdex::mapped_set::mapped_key_compare
details::tcompare< mapped_key_type, _fComp > mapped_key_compare
Definition: set.hpp:255
ystdex::mapped_set::~mapped_set
~mapped_set()=default
ystdex::map::lower_bound
iterator lower_bound(const key_type &x)
Definition: map.hpp:672
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::umap_pair
std::pair< const mapped_key_type, value_type > umap_pair
Definition: set.hpp:256
ystdex::mapped_set_traits::extend_key
static _tKey && extend_key(_tKey &&k, _tCon &&)
从参数指定的透明比较的键转换为用于插入容器值的键的值。
Definition: set.hpp:176
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
ystdex::map::size
size_type size() const
Definition: map.hpp:301
ystdex::map::count
size_type count(const key_type &x) const
Definition: map.hpp:642
ystdex::mapped_set::emplace
std::pair< iterator, bool > emplace(_tParams &&... args)
Definition: set.hpp:466
ystdex::mapped_set::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &x) const
Definition: set.hpp:775
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::key_type
ValueNode key_type
Definition: set.hpp:245
ystdex::mapped_set::mapped_key_type
details::wrapped_key< _type > mapped_key_type
Definition: set.hpp:254
ystdex::details::wrapped_key::wrapped_key
wrapped_key(const key_type &key)
Definition: set.hpp:128
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::const_reference
const value_type & const_reference
Definition: set.hpp:251
ystdex::details::tcompare< _tWrappedKey, _fComp, true >::is_transparent
void is_transparent
Definition: set.hpp:90
ystdex::details::tcompare
Definition: set.hpp:65
ystdex::mapped_set::find
iterator find(const key_type &x)
Definition: set.hpp:661
ystdex::details::wrapped_key::k
wrapper k
Definition: set.hpp:125
std
Definition: optional.h:982
ystdex::transformed_iterator::get
iterator_type & get()
取原迭代器引用。
Definition: iterator.hpp:398
ystdex::mapped_set::lower_bound
const_iterator lower_bound(const key_type &x) const
Definition: set.hpp:715
ystdex::mapped_set::amend_all
void amend_all() const
Definition: set.hpp:810
iterator.hpp
通用迭代器。
YSLib::i
return i
Definition: YCoreUtilities.h:177
ystdex::map::end
iterator end()
Definition: map.hpp:238
ystdex::map::max_size
size_type max_size() const
Definition: map.hpp:307
ystdex::mapped_set::cend
const_iterator cend() const
Definition: set.hpp:418
ystdex::rebind_alloc_t
typename allocator_traits< _tAlloc >::template rebind_alloc< _type > rebind_alloc_t
Definition: allocator.hpp:423
ystdex::mapped_set::upper_bound
iterator upper_bound(const key_type &x)
Definition: set.hpp:739
ystdex::mapped_set::iter_trans
static umap_pair iter_trans(const _tIter &i)
Definition: set.hpp:833
ystdex::mapped_set::rend
reverse_iterator rend()
Definition: set.hpp:401
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::pointer
typename allocator_traits< allocator_type >::pointer pointer
Definition: set.hpp:271
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
ystdex::mapped_set::const_iterator
wrap_iter< typename umap_type::const_iterator > const_iterator
Definition: set.hpp:268
ystdex::mapped_set::rbegin
const_reverse_iterator rbegin() const
Definition: set.hpp:395
ystdex::mapped_set::max_size
size_type max_size() const
Definition: set.hpp:448
ystdex::mapped_set::mapped_set
mapped_set(_tIn first, _tIn last, const _tAlloc &a)
Definition: set.hpp:330
ystdex::mapped_set_traits::get_value_key
static const _tKey & get_value_key(const _tKey &x, _tParams &&...)
Definition: set.hpp:190
ystdex::mapped_set::end
const_iterator end() const
Definition: set.hpp:384
ystdex::mapped_set::operator=
mapped_set & operator=(mapped_set &&)=default
ystdex::map::key_comp
key_compare key_comp() const
Definition: map.hpp:607
ystdex::map::insert
insert_return_type insert(node_type &&nh)
Definition: map.hpp:383
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:143
ystdex::mapped_set::end
iterator end()
Definition: set.hpp:379
ystdex::mapped_set::erase
iterator erase(const_iterator first, const_iterator last)
Definition: set.hpp:622
ystdex::mapped_set::mapped_set
mapped_set()
Definition: set.hpp:283
ystdex::mapped_set::emplace_hint
iterator emplace_hint(const_iterator position, _tParams &&... args)
Definition: set.hpp:474
ystdex::details::tcompare::tcompare
tcompare(_fComp c)
Definition: set.hpp:70
ystdex::mapped_set::swap
void swap(mapped_set &s)
Definition: set.hpp:629
ystdex::mapped_set::key_compare
_fComp key_compare
Definition: set.hpp:247
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::size_type
typename umap_type::size_type size_type
Definition: set.hpp:269
ystdex::mapped_set::insert_unique_impl
std::pair< typename umap_type::iterator, bool > insert_unique_impl(index_sequence< _vSeq... > seq, std::tuple< _tSeq... > pos, _tParam &&x)
Definition: set.hpp:593
ystdex::mapped_set::begin
iterator begin()
Definition: set.hpp:368
ystdex::map::upper_bound
iterator upper_bound(const key_type &x)
Definition: map.hpp:697
ystdex::mapped_set::erase
iterator erase(iterator position)
Definition: set.hpp:607
ystdex::mapped_set_traits::restore_key
static void restore_key(_type &, _tParam &&)
恢复元素的键。
Definition: set.hpp:203
ystdex::mapped_set::insert_unique
std::pair< iterator, bool > insert_unique(_tParam &&x)
Definition: set.hpp:577
ystdex::mapped_set::mapped_set
mapped_set(mapped_set &&s)
Definition: set.hpp:303
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
ystdex::mapped_set::emplace_res_conv
static std::pair< iterator, bool > emplace_res_conv(const std::pair< typename umap_type::iterator, bool > &res)
Definition: set.hpp:521
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::const_pointer
typename allocator_traits< allocator_type >::const_pointer const_pointer
Definition: set.hpp:272
ystdex::map< mapped_key_type, value_type, mapped_key_compare, rebind_alloc_t< allocator_type, umap_pair > >::const_iterator
typename rep_type::const_iterator const_iterator
Definition: map.hpp:128
ystdex::mapped_set::insert_unique_hint
iterator insert_unique_hint(iterator position, _tParam &&x)
Definition: set.hpp:585
ystdex::mapped_set::upper_bound
const_iterator upper_bound(const key_type &x) const
Definition: set.hpp:744
ystdex::mapped_set::mapped_set
mapped_set(mapped_set &&s, const _tAlloc &a)
Definition: set.hpp:320
ystdex::mapped_set::iterator
wrap_iter< typename umap_type::iterator > iterator
Definition: set.hpp:267
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::difference_type
typename umap_type::difference_type difference_type
Definition: set.hpp:270
ystdex::mapped_set::equal_range
std::pair< iterator, iterator > equal_range(const key_type &x)
Definition: set.hpp:768
ystdex::mapped_set::mapped_set
mapped_set(_tIn first, _tIn last, const _fComp &comp=_fComp(), const _tAlloc &a=_tAlloc())
Definition: set.hpp:291
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >::allocator_type
allocator_type allocator_type
Definition: set.hpp:249
ystdex::map::cend
const_iterator cend() const
Definition: map.hpp:277
ystdex::mapped_set::value_compare
_fComp value_compare
Definition: set.hpp:248
ystdex::mapped_set::erase
iterator erase(const_iterator position)
Definition: set.hpp:612
ystdex::cpp2014::integer_sequence
Definition: integer_sequence.hpp:53
ystdex::map::equal_range
std::pair< iterator, iterator > equal_range(const key_type &x)
Definition: map.hpp:722
ystdex::search_map_by
std::pair< typename _tAssocCon::const_iterator, bool > search_map_by(_func f, const _tAssocCon &con, _tParams &&... args)
按指定键值搜索指定映射并执行操作。
Definition: container.hpp:1009
ystdex::mapped_set::rbegin
reverse_iterator rbegin()
Definition: set.hpp:390
ystdex::details::wrapped_key::key_type
_type key_type
Definition: set.hpp:121
ystdex::map::empty
bool empty() const
Definition: map.hpp:295
ystdex::mapped_set::swap
friend void swap(mapped_set &x, mapped_set &y)
Definition: set.hpp:841
ystdex::mapped_set::insert
std::pair< iterator, bool > insert(value_type &&x)
Definition: set.hpp:533
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:413
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
ystdex::mapped_set::emplace_hint_impl
std::pair< iterator, bool > emplace_hint_impl(index_sequence< _vSeq... > seq, std::tuple< _tSeq... > pos, _tParams &&... args)
Definition: set.hpp:484
ystdex::mapped_set::insert_forward
static value_type insert_forward(value_type &x)
Definition: set.hpp:565
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
functor.hpp
通用仿函数。
ystdex::details::wrapped_key
Definition: set.hpp:119
ystdex::mapped_set_traits::get_value_key
static auto get_value_key() -> decltype(_type())
从可选的参数中取键的值。
Definition: set.hpp:184
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:1458
ystdex::mapped_set::erase
size_type erase(const key_type &x)
Definition: set.hpp:617
ystdex::mapped_set::lower_bound
iterator lower_bound(const key_type &x)
Definition: set.hpp:710
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:1151
ystdex::mapped_set::mapped_set
mapped_set(std::initializer_list< value_type > il, const _fComp &comp=_fComp(), const _tAlloc &a=_tAlloc())
Definition: set.hpp:325
ystdex::transformed_iterator
变换迭代器。
Definition: iterator.hpp:196
ystdex::details::tcompare::operator()
bool operator()(const _tWrappedKey &x, const _tWrappedKey &y) const
Definition: set.hpp:75
ystdex::mapped_set::amend_pair
static void amend_pair(const umap_pair &pr)
Definition: set.hpp:817
ystdex::mapped_set::begin
const_iterator begin() const
Definition: set.hpp:373
ystdex::map::cbegin
const_iterator cbegin() const
Definition: map.hpp:271
ystdex::mapped_set::emplace_search
std::pair< typename umap_type::iterator, bool > emplace_search(_func f, const _tKey &k, index_sequence< _vSeq... >, std::tuple< _tSeq... > pos)
Definition: set.hpp:507
ystdex::cpp2017::as_const
add_const_t< _type > & as_const(_type &t)
转换 const 引用。
Definition: utility.hpp:77
ystdex::details::tcompare< _tWrappedKey, _fComp, true >::operator()
bool operator()(const _tWrappedKey &x, const _tKey &y) const
Definition: set.hpp:104
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
ystdex::mapped_set::value_comp
value_compare value_comp() const
Definition: set.hpp:649
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168
NPL::_tParam
_tParam
Definition: NPLA.h:2367
ystdex::mapped_set::get_allocator
allocator_type get_allocator() const
Definition: set.hpp:362
ystdex::and_
逻辑操作元函数。
Definition: integral_constant.hpp:151
ystdex::mapped_set::insert
void insert(_tIn first, _tIn last)
Definition: set.hpp:549
ystdex::mapped_set::crend
const_reverse_iterator crend() const
Definition: set.hpp:430