36 #ifndef _GLIBCXX_PARALLEL_ALGOBASE_H
37 #define _GLIBCXX_PARALLEL_ALGOBASE_H 1
46 namespace std _GLIBCXX_VISIBILITY(default)
53 template<
typename _IIter1,
typename _IIter2>
54 inline pair<_IIter1, _IIter2>
55 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
57 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2); }
60 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
61 inline pair<_IIter1, _IIter2>
62 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
64 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
67 template<
typename _IIter1,
typename _IIter2,
68 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
69 inline pair<_IIter1, _IIter2>
70 __mismatch_switch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
71 _Predicate __pred, _IteratorTag1, _IteratorTag2)
72 {
return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred); }
75 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
76 pair<_RAIter1, _RAIter2>
77 __mismatch_switch(_RAIter1 __begin1, _RAIter1 __end1,
78 _RAIter2 __begin2, _Predicate __pred,
79 random_access_iterator_tag, random_access_iterator_tag)
86 __mismatch_selector()).first;
87 return make_pair(__res , __begin2 + (__res - __begin1));
90 return _GLIBCXX_STD_A::mismatch(__begin1, __end1, __begin2, __pred);
94 template<
typename _IIter1,
typename _IIter2>
95 inline pair<_IIter1, _IIter2>
96 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
98 typedef std::iterator_traits<_IIter1> _Iterator1Traits;
99 typedef std::iterator_traits<_IIter2> _Iterator2Traits;
100 typedef typename _Iterator1Traits::value_type _ValueType1;
101 typedef typename _Iterator2Traits::value_type _ValueType2;
102 typedef typename _Iterator1Traits::iterator_category _IteratorCategory1;
103 typedef typename _Iterator2Traits::iterator_category _IteratorCategory2;
107 return __mismatch_switch(__begin1, __end1, __begin2, _EqualTo(),
108 _IteratorCategory1(), _IteratorCategory2());
112 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
113 inline pair<_IIter1, _IIter2>
114 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
117 typedef std::iterator_traits<_IIter1> _Iterator1Traits;
118 typedef std::iterator_traits<_IIter2> _Iterator2Traits;
119 typedef typename _Iterator1Traits::iterator_category _IteratorCategory1;
120 typedef typename _Iterator2Traits::iterator_category _IteratorCategory2;
122 return __mismatch_switch(__begin1, __end1, __begin2, __pred,
123 _IteratorCategory1(), _IteratorCategory2());
127 template<
typename _IIter1,
typename _IIter2>
129 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
131 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2); }
134 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
136 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
138 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred); }
141 template<
typename _IIter1,
typename _IIter2>
143 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
145 return __gnu_parallel::mismatch(__begin1, __end1, __begin2).first
150 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
152 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
155 return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __pred).first
160 template<
typename _IIter1,
typename _IIter2>
162 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
163 _IIter2 __begin2, _IIter2 __end2,
165 {
return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
169 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
171 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
172 _IIter2 __begin2, _IIter2 __end2,
174 {
return _GLIBCXX_STD_A::lexicographical_compare(
175 __begin1, __end1, __begin2, __end2, __pred); }
178 template<
typename _IIter1,
typename _IIter2,
179 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
181 __lexicographical_compare_switch(_IIter1 __begin1, _IIter1 __end1,
182 _IIter2 __begin2, _IIter2 __end2,
184 _IteratorTag1, _IteratorTag2)
185 {
return _GLIBCXX_STD_A::lexicographical_compare(
186 __begin1, __end1, __begin2, __end2, __pred); }
190 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
192 __lexicographical_compare_switch(_RAIter1 __begin1, _RAIter1 __end1,
193 _RAIter2 __begin2, _RAIter2 __end2,
195 random_access_iterator_tag,
196 random_access_iterator_tag)
200 typedef iterator_traits<_RAIter1> _TraitsType1;
201 typedef typename _TraitsType1::value_type _ValueType1;
203 typedef iterator_traits<_RAIter2> _TraitsType2;
204 typedef typename _TraitsType2::value_type _ValueType2;
208 _EqualFromLessCompare;
211 if ((__end1 - __begin1) < (__end2 - __begin2))
213 typedef pair<_RAIter1, _RAIter2> _SpotType;
214 _SpotType __mm = __mismatch_switch(__begin1, __end1, __begin2,
215 _EqualFromLessCompare(__pred),
216 random_access_iterator_tag(),
217 random_access_iterator_tag());
219 return (__mm.first == __end1)
220 || bool(__pred(*__mm.first, *__mm.second));
224 typedef pair<_RAIter2, _RAIter1> _SpotType;
225 _SpotType __mm = __mismatch_switch(__begin2, __end2, __begin1,
226 _EqualFromLessCompare(__pred),
227 random_access_iterator_tag(),
228 random_access_iterator_tag());
230 return (__mm.first != __end2)
231 && bool(__pred(*__mm.second, *__mm.first));
235 return _GLIBCXX_STD_A::lexicographical_compare(
236 __begin1, __end1, __begin2, __end2, __pred);
240 template<
typename _IIter1,
typename _IIter2>
242 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
243 _IIter2 __begin2, _IIter2 __end2)
245 typedef iterator_traits<_IIter1> _TraitsType1;
246 typedef typename _TraitsType1::value_type _ValueType1;
247 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
249 typedef iterator_traits<_IIter2> _TraitsType2;
250 typedef typename _TraitsType2::value_type _ValueType2;
251 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
254 return __lexicographical_compare_switch(
255 __begin1, __end1, __begin2, __end2, _LessType(),
256 _IteratorCategory1(), _IteratorCategory2());
260 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
262 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
263 _IIter2 __begin2, _IIter2 __end2,
266 typedef iterator_traits<_IIter1> _TraitsType1;
267 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
269 typedef iterator_traits<_IIter2> _TraitsType2;
270 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
272 return __lexicographical_compare_switch(
273 __begin1, __end1, __begin2, __end2, __pred,
274 _IteratorCategory1(), _IteratorCategory2());
Similar to std::equal_to, but allows two different types.
Constructs predicate for equality from strict weak ordering predicate.
Runtime settings and tuning parameters, heuristics to decide whether to use parallelized algorithms...
Forces sequential execution at compile time.
Parallel implementation base for std::find(), std::equal() and related functions. This file is a GNU ...
pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
std::pair< _RAIter1, _RAIter2 > __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector)
Parallel std::find, switch for different algorithms.
Similar to std::less, but allows two different types.
#define _GLIBCXX_PARALLEL_CONDITION(__c)
Determine at compile(?)-time if the parallel variant of an algorithm should be called.
Sequential helper functions. This file is a GNU parallel extension to the Standard C++ Library...
_Function objects representing different tasks to be plugged into the parallel find algorithm...
Tags for compile-time selection. This file is a GNU parallel extension to the Standard C++ Library...