Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Parallel algorithms

 

template <class Iter, class Lambdavoid CoPartition(Iter begin, Iter end, const Lambda& lambda, int min_chunk = CO_PARTITION_MIN, int max_chunk = CO_PARTITION_MAX)

template <class Range, class Lambdavoid CoPartition(Range& r, const Lambda& lambda)

template <class Range, class Lambdavoid CoPartition(const Range& r, const Lambda& lambda, int max_chunk = 2147483647 )

Partitions a Range (possibly defined begin / end pair) into several subranges, based on number of CPU cores, and invokes lambda on them in parallel. begin / end variant passes new begin / end pair as lambda parameters, Range variant passes SubRange. Parallel processing is implemented by CoWork, which means CoWork::FinLock is available in lambda.

 


 

template <class Range, class Accumulatorvoid CoAccumulate(Range r, Accumulator& result)

r result .

 


 

template <class RangeValueTypeOf<RangeCoSum(const Range& r, const ValueTypeOf<Range>& zero)

Returns the sum of all elements in range r, with zero representing initial zero value. T must have defined operator+=. Runs in parallel, operator+= must be reentrant.

 


 

template <class TValueTypeOf<TCoSum(const T& c)

Same as CoSum(c, 0).

 


 

template <class Range, class Vint CoCount(const Range& r, const V& val)

Counts the number of elements in the Range r that are equal to val. Runs in parallel.

 


 

template <class Range, class Predicateint CoCountIf(const Range& r, const Predicate& p)

Counts the number of elements in the Range r that satisfy condition p. Runs in parallel, p must be reentrant.

 


 

template <class Range, class Betterint CoFindBest(const Range& r, const Better& better)

Finds the most suitable element in a range r as specified by pred. E.g. if pred is std::less, finds minimum. If r is empty, returns -1. Runs in parallel, better must be reentrant.

 


 

template <class Rangeint CoFindMin(const Range& r)

Returns the index of minimal element of r, using std::less to compare elements. If r is empty, returns -1. Runs in parallel, std::less must be reentrant.

 


 

template <class Rangeconst ValueTypeOf<Range>& CoMin(const Range& r)

Returns the value of minimal element of r, using std::less to compare elements. If r is empty, behavior is undefined (ASSERT fails in debug). Runs in parallel, std::less must be reentrant.

 


 

template <class Rangeconst ValueTypeOf<Range>& CoMin(const Range& r, const ValueTypeOf<Range>& def)

Returns the value of minimal element of r, using std::less to compare elements. If r is empty, returns def. Runs in parallel, std::less must be reentrant.

 


 

template <class Rangeint CoFindMax(const Range& r)

Returns the index of maximal element of r, using std::greater to compare elements. If r is empty, returns -1. Runs in parallel, std::greater must be reentrant.

 


 

template <class Rangeconst ValueTypeOf<Range>& CoMax(const Range& r)

Returns the value of maximal element of r, using std::less to compare elements. If r is empty, behavior is undefined (ASSERT fails in debug). Runs in parallel, std::greater must be reentrant.

 


 

template <class Rangeconst ValueTypeOf<Range>& CoMax(const Range& r, const ValueTypeOf<Range>& def)

Returns the value of maximal element of r, using std::less to compare elements. If r is empty, returns def. Runs in parallel, std::greater must be reentrant.

 


 

template <class Range, class Matchint CoFindMatch(const Range& r, const Match& eq, int from = 0)

Returns the index of first element for which predicate match is true. If not found, returns -1. Search starts at index from. Runs in parallel, eq must be reentrant.

 


 

template <class Range, class Vint CoFindIndex(const Range& r, const V& value, int from = 0)

Returns the index of first element which is equal to value. If not found, returns -1. Search starts at index from. Runs in parallel, operator== must be reentrant.

 


 

template <class Range1, class Range2int CoIsEqualRange(const Range1& r1, const Range2& r2)

Returns true if a and b are equal. operator== is used to compare elements. Ranges are considered equal if they have the same number of elements and for every element at index i: a[i] == b[i]. Runs in parallel, operator== must be reentrant.

 


 

template <class Range, class PredicateVector<intCoFindAll(const Range& r, Predicate match, int from = 0)

Returns the Vector of indices of ALL elements for which match is true. Returned Vector is sorted in ascending order. Search starts at index from. Runs in parallel, match must be reentrant.

 

Last edit by cxl on 11/27/2016. Do you want to contribute?. T++