17 #ifndef STXXL_PARALLEL_MERGE_HEADER
18 #define STXXL_PARALLEL_MERGE_HEADER
44 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
45 typename OutputIterator,
46 typename DiffType,
typename Comparator>
49 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
50 OutputIterator target, DiffType max_length,
53 while (begin1 != end1 && begin2 != end2 && max_length > 0)
56 if (comp(*begin2, *begin1))
57 *target++ = *begin2++;
59 *target++ = *begin1++;
65 target = std::copy(begin1, begin1 + max_length, target);
70 target = std::copy(begin2, begin2 + max_length, target);
92 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
93 typename OutputIterator,
94 typename DiffType,
typename Comparator>
97 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
98 OutputIterator target,
99 DiffType max_length, Comparator comp)
101 typedef typename std::iterator_traits<RandomAccessIterator1>::value_type ValueType1;
102 typedef typename std::iterator_traits<RandomAccessIterator2>::value_type ValueType2;
104 while (begin1 != end1 && begin2 != end2 && max_length > 0)
106 RandomAccessIterator1 next1 = begin1 + 1;
107 RandomAccessIterator2 next2 = begin2 + 1;
108 ValueType1 element1 = *begin1;
109 ValueType2 element2 = *begin2;
111 if (comp(element2, element1))
129 target = std::copy(begin1, begin1 + max_length, target);
130 begin1 += max_length;
134 target = std::copy(begin2, begin2 + max_length, target);
135 begin2 += max_length;
157 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
158 typename OutputIterator,
159 typename DiffType,
typename Comparator>
162 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
163 OutputIterator target,
164 DiffType max_length, Comparator comp)
184 template <
typename RandomAccessIterator1,
typename RandomAccessIterator2,
185 typename RandomAccessIterator3,
typename Comparator>
186 RandomAccessIterator3
188 RandomAccessIterator1& begin1, RandomAccessIterator1 end1,
189 RandomAccessIterator2& begin2, RandomAccessIterator2 end2,
191 RandomAccessIterator3 target,
192 typename std::iterator_traits<RandomAccessIterator1>::difference_type max_length,
195 return merge_advance(begin1, end1, begin2, end2, target, max_length, comp);
215 template <
typename RandomAccessIterator1,
typename RandomAccessIterator3,
217 RandomAccessIterator3
219 RandomAccessIterator1& begin1, RandomAccessIterator1 end1,
220 RandomAccessIterator1& begin2, RandomAccessIterator1 end2,
221 RandomAccessIterator3 target,
222 typename std::iterator_traits<RandomAccessIterator1>::difference_type max_length,
225 std::pair<RandomAccessIterator1, RandomAccessIterator1> seqs[2] = {
226 std::make_pair(begin1, end1), std::make_pair(begin2, end2)
228 RandomAccessIterator3 target_end = parallel_multiway_merge(
229 seqs, seqs + 2, target, comp, max_length,
true,
false
239 #endif // !STXXL_PARALLEL_MERGE_HEADER
OutputIterator merge_advance(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_length, Comparator comp)
Merge routine being able to merge only the max_length smallest elements.
#define STXXL_BEGIN_NAMESPACE
#define STXXL_PARALLEL_PCALL(n)
OutputIterator merge_advance_movc(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_length, Comparator comp)
Merge routine being able to merge only the max_length smallest elements.
RandomAccessIterator3 parallel_merge_advance(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, RandomAccessIterator3 target, typename std::iterator_traits< RandomAccessIterator1 >::difference_type max_length, Comparator comp)
Merge routine fallback to sequential in case the iterators of the two input sequences are of differen...
OutputIterator merge_advance_usual(RandomAccessIterator1 &begin1, RandomAccessIterator1 end1, RandomAccessIterator2 &begin2, RandomAccessIterator2 end2, OutputIterator target, DiffType max_length, Comparator comp)
Merge routine being able to merge only the max_length smallest elements.
#define STXXL_END_NAMESPACE