32 #ifndef _GLIBCXX_PARALLEL_MERGE_H
33 #define _GLIBCXX_PARALLEL_MERGE_H 1
38 namespace __gnu_parallel
53 template<
typename _RAIter1,
typename _RAIter2,
54 typename _OutputIterator,
typename _DifferenceTp,
58 _RAIter2& __begin2, _RAIter2 __end2,
59 _OutputIterator __target,
60 _DifferenceTp __max_length, _Compare __comp)
62 typedef _DifferenceTp _DifferenceType;
63 while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0)
66 if (__comp(*__begin2, *__begin1))
67 *__target++ = *__begin2++;
69 *__target++ = *__begin1++;
73 if (__begin1 != __end1)
75 __target = std::copy(__begin1, __begin1 + __max_length, __target);
76 __begin1 += __max_length;
80 __target = std::copy(__begin2, __begin2 + __max_length, __target);
81 __begin2 += __max_length;
101 template<
typename _RAIter1,
typename _RAIter2,
102 typename _OutputIterator,
typename _DifferenceTp,
106 _RAIter2& __begin2, _RAIter2 __end2,
107 _OutputIterator __target,
108 _DifferenceTp __max_length, _Compare __comp)
110 typedef _DifferenceTp _DifferenceType;
111 typedef typename std::iterator_traits<_RAIter1>::value_type
113 typedef typename std::iterator_traits<_RAIter2>::value_type
116 #if _GLIBCXX_ASSERTIONS
117 _GLIBCXX_PARALLEL_ASSERT(__max_length >= 0);
120 while (__begin1 != __end1 && __begin2 != __end2 && __max_length > 0)
122 _RAIter1 __next1 = __begin1 + 1;
123 _RAIter2 __next2 = __begin2 + 1;
124 _ValueType1 __element1 = *__begin1;
125 _ValueType2 __element2 = *__begin2;
127 if (__comp(__element2, __element1))
129 __element1 = __element2;
135 *__target = __element1;
140 if (__begin1 != __end1)
142 __target = std::copy(__begin1, __begin1 + __max_length, __target);
143 __begin1 += __max_length;
147 __target = std::copy(__begin2, __begin2 + __max_length, __target);
148 __begin2 += __max_length;
167 template<
typename _RAIter1,
typename _RAIter2,
168 typename _OutputIterator,
typename _DifferenceTp,
170 inline _OutputIterator
172 _RAIter2& __begin2, _RAIter2 __end2,
173 _OutputIterator __target, _DifferenceTp __max_length,
179 __target, __max_length, __comp);
192 template<
typename _RAIter1,
typename _RAIter2,
193 typename _RAIter3,
typename _Compare>
199 _RAIter2 __end2, _RAIter3 __target,
typename
200 std::iterator_traits<_RAIter1>::
201 difference_type __max_length, _Compare __comp)
203 __max_length, __comp); }
220 template<
typename _RAIter1,
typename _RAIter3,
224 _RAIter1& __begin2, _RAIter1 __end2,
225 _RAIter3 __target,
typename
226 std::iterator_traits<_RAIter1>::
227 difference_type __max_length, _Compare __comp)
230 std::iterator_traits<_RAIter1>::value_type _ValueType;
231 typedef typename std::iterator_traits<_RAIter1>::
232 difference_type _DifferenceType1 ;
233 typedef typename std::iterator_traits<_RAIter3>::
234 difference_type _DifferenceType3;
243 <
true, _IteratorPair*,
244 _Compare, _DifferenceType1>, __max_length, __comp,
245 omp_get_max_threads());