18 #ifndef TLX_ALGORITHM_MERGE_ADVANCE_HEADER 19 #define TLX_ALGORITHM_MERGE_ADVANCE_HEADER 43 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
44 typename OutputIterator,
45 typename DiffType,
typename Comparator>
48 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
49 OutputIterator target, DiffType max_size,
51 while (begin1 != end1 && begin2 != end2 && max_size > 0)
54 if (comp(*begin2, *begin1))
55 *target++ = *begin2++;
57 *target++ = *begin1++;
63 target = std::copy(begin1, begin1 + max_size, target);
68 target = std::copy(begin2, begin2 + max_size, target);
90 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
91 typename OutputIterator,
92 typename DiffType,
typename Comparator>
95 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
96 OutputIterator target,
97 DiffType max_size, Comparator comp) {
98 using ValueType1 =
typename std::iterator_traits<RandomAccessIterator1>::value_type;
99 using ValueType2 =
typename std::iterator_traits<RandomAccessIterator2>::value_type;
101 while (begin1 != end1 && begin2 != end2 && max_size > 0)
103 RandomAccessIterator1 next1 = begin1 + 1;
104 RandomAccessIterator2 next2 = begin2 + 1;
105 ValueType1 element1 = *begin1;
106 ValueType2 element2 = *begin2;
108 if (comp(element2, element1))
126 target = std::copy(begin1, begin1 + max_size, target);
131 target = std::copy(begin2, begin2 + max_size, target);
154 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
155 typename OutputIterator,
156 typename DiffType,
typename Comparator>
159 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
160 OutputIterator target,
161 DiffType max_size, Comparator comp) {
163 begin1, end1, begin2, end2, target, max_size, comp);
170 #endif // !TLX_ALGORITHM_MERGE_ADVANCE_HEADER OutputIterator merge_advance(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_size, Comparator comp)
Merge routine being able to merge only the max_size smallest elements.
OutputIterator merge_advance_movc(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_size, Comparator comp)
Merge routine being able to merge only the max_size smallest elements.
OutputIterator merge_advance_usual(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_size, Comparator comp)
Merge routine being able to merge only the max_size smallest elements.