36#ifndef _GLIBCXX_PARALLEL_ALGOBASE_H
37#define _GLIBCXX_PARALLEL_ALGOBASE_H 1
45namespace std _GLIBCXX_VISIBILITY(default)
52 template<
typename _IIter1,
typename _IIter2>
53 inline pair<_IIter1, _IIter2>
54 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
56 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2); }
59 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
60 inline pair<_IIter1, _IIter2>
61 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
63 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
66 template<
typename _IIter1,
typename _IIter2,
67 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
68 inline pair<_IIter1, _IIter2>
69 __mismatch_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
70 _Predicate __pred, _IteratorTag1, _IteratorTag2)
71 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
74 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
75 pair<_RAIter1, _RAIter2>
76 __mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1,
77 _RAIter2 __begin2, _Predicate __pred,
78 random_access_iterator_tag, random_access_iterator_tag)
85 __mismatch_selector()).first;
86 return make_pair(__res , __begin2 + (__res - __begin1));
89 return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred);
93 template<
typename _IIter1,
typename _IIter2>
94 inline pair<_IIter1, _IIter2>
95 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
101 return __mismatch_switch(__begin1, __end1, __begin2, _EqualTo(),
107 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
108 inline pair<_IIter1, _IIter2>
109 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
112 return __mismatch_switch(__begin1, __end1, __begin2, __pred,
117#if __cplusplus > 201103L
119 template<
typename _InputIterator1,
typename _InputIterator2>
120 inline pair<_InputIterator1, _InputIterator2>
121 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
122 _InputIterator2 __first2, _InputIterator2 __last2,
124 {
return _GLIBCXX_STD_A::mismatch(__first1, __last1, __first2, __last2); }
127 template<
typename _InputIterator1,
typename _InputIterator2,
128 typename _BinaryPredicate>
129 inline pair<_InputIterator1, _InputIterator2>
130 mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
131 _InputIterator2 __first2, _InputIterator2 __last2,
132 _BinaryPredicate __binary_pred,
135 return _GLIBCXX_STD_A::mismatch(__first1, __last1, __first2, __last2,
140 template<
typename _IIter1,
typename _IIter2,
141 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
142 inline pair<_IIter1, _IIter2>
143 __mismatch_switch(_IIter1 __begin1, _IIter1 __end1,
144 _IIter2 __begin2, _IIter2 __end2, _Predicate __pred,
145 _IteratorTag1, _IteratorTag2)
147 return _GLIBCXX_STD_A::mismatch(__begin1, __end1,
148 __begin2, __end2, __pred);
152 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
153 pair<_RAIter1, _RAIter2>
154 __mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1,
155 _RAIter2 __begin2, _RAIter2 __end2, _Predicate __pred,
156 random_access_iterator_tag, random_access_iterator_tag)
160 if ((__end2 - __begin2) < (__end1 - __begin1))
161 __end1 = __begin1 + (__end2 - __begin2);
166 __mismatch_selector()).first;
167 return make_pair(__res , __begin2 + (__res - __begin1));
170 return _GLIBCXX_STD_A::mismatch(__begin1, __end1,
171 __begin2, __end2, __pred);
174 template<
typename _IIter1,
typename _IIter2>
175 inline pair<_IIter1, _IIter2>
176 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2)
182 return __mismatch_switch(__begin1, __end1, __begin2, __end2, _EqualTo(),
187 template<
typename _InputIterator1,
typename _InputIterator2,
188 typename _BinaryPredicate>
189 inline pair<_InputIterator1, _InputIterator2>
190 mismatch(_InputIterator1 __begin1, _InputIterator1 __end1,
191 _InputIterator2 __begin2, _InputIterator2 __end2,
192 _BinaryPredicate __binary_pred)
194 return __mismatch_switch(__begin1, __end1, __begin2, __end2,
202 template<
typename _IIter1,
typename _IIter2>
204 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
206 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2); }
209 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
211 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
213 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred); }
216 template<
typename _IIter1,
typename _IIter2>
219 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
221#if __cplusplus > 201703L
222 if (std::is_constant_evaluated())
223 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2);
226 return __gnu_parallel::mismatch(__begin1, __end1, __begin2).first
231 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
234 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
237#if __cplusplus > 201703L
238 if (std::is_constant_evaluated())
239 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred);
242 return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __pred).first
246#if __cplusplus > 201103L
248 template<
typename _IIter1,
typename _IIter2>
250 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2,
253 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2);
257 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
259 equal(_IIter1 __begin1, _IIter1 __end1,
260 _IIter2 __begin2, _IIter2 __end2, _BinaryPredicate __binary_pred,
263 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2,
268 template<
typename _IIter1,
typename _IIter2,
269 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
271 __equal_switch(_IIter1 __begin1, _IIter1 __end1,
272 _IIter2 __begin2, _IIter2 __end2, _Predicate __pred,
273 _IteratorTag1, _IteratorTag2)
275 return _GLIBCXX_STD_A::equal(__begin1, __end1,
276 __begin2, __end2, __pred);
280 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
282 __equal_switch(_RAIter1 __begin1, _RAIter1 __end1,
283 _RAIter2 __begin2, _RAIter2 __end2, _Predicate __pred,
284 random_access_iterator_tag, random_access_iterator_tag)
292 return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __end2,
293 __pred).first == __end1;
296 return _GLIBCXX_STD_A::equal(__begin1, __end1,
297 __begin2, __end2, __pred);
300 template<
typename _IIter1,
typename _IIter2>
303 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _IIter2 __end2)
305#if __cplusplus > 201703L
306 if (std::is_constant_evaluated())
307 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2);
314 return __equal_switch(__begin1, __end1, __begin2, __end2, _EqualTo(),
319 template<
typename _IIter1,
typename _IIter2,
typename _BinaryPredicate>
322 equal(_IIter1 __begin1, _IIter1 __end1,
323 _IIter2 __begin2, _IIter2 __end2, _BinaryPredicate __binary_pred)
325#if __cplusplus > 201703L
326 if (std::is_constant_evaluated())
327 return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __end2,
331 return __equal_switch(__begin1, __end1, __begin2, __end2, __binary_pred,
338 template<
typename _IIter1,
typename _IIter2>
340 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
341 _IIter2 __begin2, _IIter2 __end2,
343 {
return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
347 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
349 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
350 _IIter2 __begin2, _IIter2 __end2,
352 {
return _GLIBCXX_STD_A::lexicographical_compare(
353 __begin1, __end1, __begin2, __end2, __pred); }
356 template<
typename _IIter1,
typename _IIter2,
357 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
359 __lexicographical_compare_switch(_IIter1 __begin1, _IIter1 __end1,
360 _IIter2 __begin2, _IIter2 __end2,
362 _IteratorTag1, _IteratorTag2)
363 {
return _GLIBCXX_STD_A::lexicographical_compare(
364 __begin1, __end1, __begin2, __end2, __pred); }
368 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
370 __lexicographical_compare_switch(_RAIter1 __begin1, _RAIter1 __end1,
371 _RAIter2 __begin2, _RAIter2 __end2,
373 random_access_iterator_tag,
374 random_access_iterator_tag)
378 typedef iterator_traits<_RAIter1> _TraitsType1;
379 typedef typename _TraitsType1::value_type _ValueType1;
381 typedef iterator_traits<_RAIter2> _TraitsType2;
382 typedef typename _TraitsType2::value_type _ValueType2;
384 typedef __gnu_parallel::
385 _EqualFromLess<_ValueType1, _ValueType2, _Predicate>
386 _EqualFromLessCompare;
389 if ((__end1 - __begin1) < (__end2 - __begin2))
391 typedef pair<_RAIter1, _RAIter2> _SpotType;
392 _SpotType __mm = __mismatch_switch(__begin1, __end1, __begin2,
393 _EqualFromLessCompare(__pred),
394 random_access_iterator_tag(),
395 random_access_iterator_tag());
397 return (__mm.first == __end1)
398 || bool(__pred(*__mm.first, *__mm.second));
402 typedef pair<_RAIter2, _RAIter1> _SpotType;
403 _SpotType __mm = __mismatch_switch(__begin2, __end2, __begin1,
404 _EqualFromLessCompare(__pred),
405 random_access_iterator_tag(),
406 random_access_iterator_tag());
408 return (__mm.first != __end2)
409 && bool(__pred(*__mm.second, *__mm.first));
413 return _GLIBCXX_STD_A::lexicographical_compare(
414 __begin1, __end1, __begin2, __end2, __pred);
418 template<
typename _IIter1,
typename _IIter2>
421 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
422 _IIter2 __begin2, _IIter2 __end2)
424#if __cplusplus > 201703L
425 if (std::is_constant_evaluated())
426 return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
430 typedef iterator_traits<_IIter1> _TraitsType1;
431 typedef typename _TraitsType1::value_type _ValueType1;
432 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
434 typedef iterator_traits<_IIter2> _TraitsType2;
435 typedef typename _TraitsType2::value_type _ValueType2;
436 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
439 return __lexicographical_compare_switch(
440 __begin1, __end1, __begin2, __end2, _LessType(),
441 _IteratorCategory1(), _IteratorCategory2());
445 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
448 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
449 _IIter2 __begin2, _IIter2 __end2,
452#if __cplusplus > 201703L
453 if (std::is_constant_evaluated())
454 return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
459 typedef iterator_traits<_IIter1> _TraitsType1;
460 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
462 typedef iterator_traits<_IIter2> _TraitsType2;
463 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
465 return __lexicographical_compare_switch(
466 __begin1, __end1, __begin2, __end2, __pred,
467 _IteratorCategory1(), _IteratorCategory2());
470#if __cpp_lib_three_way_comparison
471 using _GLIBCXX_STD_A::lexicographical_compare_three_way;
#define _GLIBCXX_PARALLEL_CONDITION(__c)
Determine at compile(?)-time if the parallel variant of an algorithm should be called.
_Function objects representing different tasks to be plugged into the parallel find algorithm....
Parallel implementation base for std::find(), std::equal() and related functions. This file is a GNU ...
Sequential helper functions. This file is a GNU parallel extension to the Standard C++ Library.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
GNU parallel code for public use.
std::pair< _RAIter1, _RAIter2 > __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector)
Parallel std::find, switch for different algorithms.
Traits class for iterators.
Similar to std::equal_to, but allows two different types.
Similar to std::less, but allows two different types.
Forces sequential execution at compile time.