36 #ifndef _GLIBCXX_PARALLEL_ALGOBASE_H
37 #define _GLIBCXX_PARALLEL_ALGOBASE_H 1
45 namespace 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)
97 typedef std::iterator_traits<_IIter1> _Iterator1Traits;
98 typedef std::iterator_traits<_IIter2> _Iterator2Traits;
99 typedef typename _Iterator1Traits::value_type _ValueType1;
100 typedef typename _Iterator2Traits::value_type _ValueType2;
101 typedef typename _Iterator1Traits::iterator_category _IteratorCategory1;
102 typedef typename _Iterator2Traits::iterator_category _IteratorCategory2;
106 return __mismatch_switch(__begin1, __end1, __begin2, _EqualTo(),
107 _IteratorCategory1(), _IteratorCategory2());
111 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
112 inline pair<_IIter1, _IIter2>
113 mismatch(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
116 typedef std::iterator_traits<_IIter1> _Iterator1Traits;
117 typedef std::iterator_traits<_IIter2> _Iterator2Traits;
118 typedef typename _Iterator1Traits::iterator_category _IteratorCategory1;
119 typedef typename _Iterator2Traits::iterator_category _IteratorCategory2;
121 return __mismatch_switch(__begin1, __end1, __begin2, __pred,
122 _IteratorCategory1(), _IteratorCategory2());
126 template<
typename _IIter1,
typename _IIter2>
128 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
130 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2); }
133 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
135 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
137 {
return _GLIBCXX_STD_A::equal(__begin1, __end1, __begin2, __pred); }
140 template<
typename _IIter1,
typename _IIter2>
142 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
144 return __gnu_parallel::mismatch(__begin1, __end1, __begin2).first
149 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
151 equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
154 return __gnu_parallel::mismatch(__begin1, __end1, __begin2, __pred).first
159 template<
typename _IIter1,
typename _IIter2>
161 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
162 _IIter2 __begin2, _IIter2 __end2,
164 {
return _GLIBCXX_STD_A::lexicographical_compare(__begin1, __end1,
168 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
170 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
171 _IIter2 __begin2, _IIter2 __end2,
173 {
return _GLIBCXX_STD_A::lexicographical_compare(
174 __begin1, __end1, __begin2, __end2, __pred); }
177 template<
typename _IIter1,
typename _IIter2,
178 typename _Predicate,
typename _IteratorTag1,
typename _IteratorTag2>
180 __lexicographical_compare_switch(_IIter1 __begin1, _IIter1 __end1,
181 _IIter2 __begin2, _IIter2 __end2,
183 _IteratorTag1, _IteratorTag2)
184 {
return _GLIBCXX_STD_A::lexicographical_compare(
185 __begin1, __end1, __begin2, __end2, __pred); }
189 template<
typename _RAIter1,
typename _RAIter2,
typename _Predicate>
191 __lexicographical_compare_switch(_RAIter1 __begin1, _RAIter1 __end1,
192 _RAIter2 __begin2, _RAIter2 __end2,
194 random_access_iterator_tag,
195 random_access_iterator_tag)
199 typedef iterator_traits<_RAIter1> _TraitsType1;
200 typedef typename _TraitsType1::value_type _ValueType1;
202 typedef iterator_traits<_RAIter2> _TraitsType2;
203 typedef typename _TraitsType2::value_type _ValueType2;
207 _EqualFromLessCompare;
210 if ((__end1 - __begin1) < (__end2 - __begin2))
212 typedef pair<_RAIter1, _RAIter2> _SpotType;
213 _SpotType __mm = __mismatch_switch(__begin1, __end1, __begin2,
214 _EqualFromLessCompare(__pred),
215 random_access_iterator_tag(),
216 random_access_iterator_tag());
218 return (__mm.first == __end1)
219 || bool(__pred(*__mm.first, *__mm.second));
223 typedef pair<_RAIter2, _RAIter1> _SpotType;
224 _SpotType __mm = __mismatch_switch(__begin2, __end2, __begin1,
225 _EqualFromLessCompare(__pred),
226 random_access_iterator_tag(),
227 random_access_iterator_tag());
229 return (__mm.first != __end2)
230 && bool(__pred(*__mm.second, *__mm.first));
234 return _GLIBCXX_STD_A::lexicographical_compare(
235 __begin1, __end1, __begin2, __end2, __pred);
239 template<
typename _IIter1,
typename _IIter2>
241 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
242 _IIter2 __begin2, _IIter2 __end2)
244 typedef iterator_traits<_IIter1> _TraitsType1;
245 typedef typename _TraitsType1::value_type _ValueType1;
246 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
248 typedef iterator_traits<_IIter2> _TraitsType2;
249 typedef typename _TraitsType2::value_type _ValueType2;
250 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
253 return __lexicographical_compare_switch(
254 __begin1, __end1, __begin2, __end2, _LessType(),
255 _IteratorCategory1(), _IteratorCategory2());
259 template<
typename _IIter1,
typename _IIter2,
typename _Predicate>
261 lexicographical_compare(_IIter1 __begin1, _IIter1 __end1,
262 _IIter2 __begin2, _IIter2 __end2,
265 typedef iterator_traits<_IIter1> _TraitsType1;
266 typedef typename _TraitsType1::iterator_category _IteratorCategory1;
268 typedef iterator_traits<_IIter2> _TraitsType2;
269 typedef typename _TraitsType2::iterator_category _IteratorCategory2;
271 return __lexicographical_compare_switch(
272 __begin1, __end1, __begin2, __end2, __pred,
273 _IteratorCategory1(), _IteratorCategory2());
_Function objects representing different tasks to be plugged into the parallel find algorithm...
GNU parallel code for public use.
Sequential helper functions. This file is a GNU parallel extension to the Standard C++ Library...
Forces sequential execution at compile time.
Parallel implementation base for std::find(), std::equal() and related functions. This file is a GNU ...
constexpr 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.
Similar to std::equal_to, but allows two different types.
ISO C++ entities toplevel namespace is std.
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.
Constructs predicate for equality from strict weak ordering predicate.
std::pair< _RAIter1, _RAIter2 > __find_template(_RAIter1 __begin1, _RAIter1 __end1, _RAIter2 __begin2, _Pred __pred, _Selector __selector)
Parallel std::find, switch for different algorithms.