32 #ifndef _GLIBCXX_PARALLEL_BASE_H
33 #define _GLIBCXX_PARALLEL_BASE_H 1
48 namespace std _GLIBCXX_VISIBILITY(default)
50 namespace __parallel { }
57 namespace __gnu_parallel
60 using namespace std::__parallel;
67 namespace __gnu_sequential
70 #ifdef _GLIBCXX_PARALLEL
71 using namespace std::_GLIBCXX_STD_A;
78 namespace __gnu_parallel
88 return __i > 1 ? __i : 1;
100 template<
typename _Size>
105 for (__k = 0; __n > 1; __n >>= 1)
142 template<
typename _Tp>
144 min(
const _Tp& __a,
const _Tp& __b)
145 {
return (__a < __b) ? __a : __b; }
148 template<
typename _Tp>
150 max(
const _Tp& __a,
const _Tp& __b)
151 {
return (__a > __b) ? __a : __b; }
156 template<
typename _T1,
typename _T2,
typename _Compare>
165 bool operator()(
const _T1& __a,
const _T2& __b)
166 {
return !_M_comp(__a, __b) && !_M_comp(__b, __a); }
172 template<
typename _Predicate,
typename argument_type>
185 {
return !_M_pred(__x); }
190 template<
typename _Operation,
typename _FirstArgumentType,
191 typename _SecondArgumentType,
typename _ResultType>
197 _FirstArgumentType _M_value;
200 __binder1st(
const _Operation& __x,
const _FirstArgumentType& __y)
201 : _M_op(__x), _M_value(__y) { }
204 operator()(
const _SecondArgumentType& __x)
205 {
return _M_op(_M_value, __x); }
210 operator()(_SecondArgumentType& __x)
const
211 {
return _M_op(_M_value, __x); }
218 template<
typename _Operation,
typename _FirstArgumentType,
219 typename _SecondArgumentType,
typename _ResultType>
225 _SecondArgumentType _M_value;
228 __binder2nd(
const _Operation& __x,
const _SecondArgumentType& __y)
229 : _M_op(__x), _M_value(__y) { }
232 operator()(
const _FirstArgumentType& __x)
const
233 {
return _M_op(__x, _M_value); }
238 operator()(_FirstArgumentType& __x)
239 {
return _M_op(__x, _M_value); }
243 template<
typename _T1,
typename _T2>
246 bool operator()(
const _T1& __t1,
const _T2& __t2)
const
247 {
return __t1 == __t2; }
251 template<
typename _T1,
typename _T2>
255 operator()(
const _T1& __t1,
const _T2& __t2)
const
256 {
return __t1 < __t2; }
259 operator()(
const _T2& __t2,
const _T1& __t1)
const
260 {
return __t2 < __t1; }
264 template<
typename _Tp>
265 struct _Less<_Tp, _Tp>
269 template<
typename _Tp1,
typename _Tp2,
typename _Result
270 = __typeof__(*static_cast<_Tp1*>(0)
271 + *static_cast<_Tp2*>(0))>
275 operator()(
const _Tp1& __x,
const _Tp2& __y)
const
276 {
return __x + __y; }
280 template<
typename _Tp>
281 struct _Plus<_Tp, _Tp, _Tp>
285 template<
typename _Tp1,
typename _Tp2,
typename _Result
286 = __typeof__(*static_cast<_Tp1*>(0)
287 * *static_cast<_Tp2*>(0))>
291 operator()(
const _Tp1& __x,
const _Tp2& __y)
const
292 {
return __x * __y; }
296 template<
typename _Tp>
305 template<
typename _Tp,
typename _DifferenceTp>
309 typedef _DifferenceTp _DifferenceType;
312 : _M_val(__val), _M_pos(__pos) { }
337 {
return _M_pos == __i2._M_pos; }
341 {
return _M_pos != __i2._M_pos; }
345 {
return _M_pos - __i2._M_pos; }
349 _DifferenceType _M_pos;
358 template<
typename _Tp,
typename _DifferenceTp>
362 typedef _DifferenceTp _DifferenceType;
372 : _M_val(__val), _M_count(__count) { }
382 {
return iterator(_M_val, _M_count); }
386 _DifferenceType _M_count;
396 template<
typename _RAIter,
typename _Compare>
399 _RAIter __c, _Compare __comp)
401 if (__comp(*__a, *__b))
402 if (__comp(*__b, *__c))
405 if (__comp(*__a, *__c))
412 if (__comp(*__a, *__c))
415 if (__comp(*__b, *__c))
422 #define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert(_Condition)