Embedded Multicore Building Blocks V1.0.0
Functions

Parallel count operation. More...

Functions

template<typename RAI , typename ValueType >
std::iterator_traits< RAI >::difference_type embb::algorithms::Count (RAI first, RAI last, const ValueType &value, const embb::mtapi::ExecutionPolicy &policy=embb::mtapi::ExecutionPolicy(), size_t block_size=0)
 Counts in parallel the number of elements in a range that are equal to the specified value. More...
 
template<typename RAI , typename ComparisonFunction >
std::iterator_traits< RAI >::difference_type embb::algorithms::CountIf (RAI first, ComparisonFunction comparison, const embb::mtapi::ExecutionPolicy &policy=embb::mtapi::ExecutionPolicy(), size_t block_size=0)
 Counts in parallel the number of elements in a range for which the comparison function returns true. More...
 

Detailed Description

Parallel count operation.

Function Documentation

template<typename RAI , typename ValueType >
std::iterator_traits<RAI>::difference_type embb::algorithms::Count ( RAI  first,
RAI  last,
const ValueType &  value,
const embb::mtapi::ExecutionPolicy policy = embb::mtapi::ExecutionPolicy(),
size_t  block_size = 0 
)

Counts in parallel the number of elements in a range that are equal to the specified value.

The range consists of the elements from first to last, excluding the last element.

Returns
The number of elements that are equal to value
Exceptions
embb::base::ErrorExceptionif not enough MTAPI tasks can be created to satisfy the requirements of the algorithm.
Concurrency
Thread-safe if the elements in the range are not modified by another thread while the algorithm is executed.
Note
No guarantee is given on the execution order of the comparison operations.
For nested algorithms, the task limit may be exceeded. In that case, increase the task limit of the MTAPI node.
See also
CountIf(), embb::mtapi::ExecutionPolicy
Template Parameters
RAIRandom access iterator
ValueTypeType of value that is compared to the elements in the range using the operator==.
Parameters
[in]firstRandom access iterator pointing to the first element of the range
[in]lastRandom access iterator pointing to the last plus one element of the range
[in]valueValue that the elements in the range are compared to using operator==
[in]policyembb::mtapi::ExecutionPolicy for the counting algorithm
[in]block_sizeLower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size is less than or equal to block_size. The default value 0 means that the minimum block size is determined automatically depending on the number of elements in the range divided by the number of available cores.
template<typename RAI , typename ComparisonFunction >
std::iterator_traits<RAI>::difference_type embb::algorithms::CountIf ( RAI  first,
ComparisonFunction  comparison,
const embb::mtapi::ExecutionPolicy policy = embb::mtapi::ExecutionPolicy(),
size_t  block_size = 0 
)

Counts in parallel the number of elements in a range for which the comparison function returns true.

The range consists of the elements from first to last, excluding the last element.

Returns
The number of elements for which comparison returns true
Exceptions
embb::base::ErrorExceptionif not enough MTAPI tasks can be created to satisfy the requirements of the algorithm.
Concurrency
Thread-safe if the elements in the range are not modified by another thread while the algorithm is executed.
Note
No guarantee is given on the execution order of the comparison function.
For nested algorithms, the task limit may be exceeded. In that case, increase the task limit of the MTAPI node.
See also
Count(), embb::mtapi::ExecutionPolicy
Template Parameters
RAIRandom access iterator
ComparisonFunctionUnary predicate with argument of type std::iterator_traits<RAI>::value_type or an embb::mtapi::Job associated with an action function accepting a struct containing one member of type std::iterator_traits<RAI>::value_type as its argument buffer and a struct containing one bool member as its result buffer.
Parameters
[in]firstRandom access iterator pointing to the first element of the range RAI last, [IN] Random access iterator pointing to the last plus one element of the range
[in]comparisonUnary predicate used to test the elements in the range. Elements for which comparison returns true are counted.
[in]policyembb::mtapi::ExecutionPolicy for the counting algorithm
[in]block_sizeLower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size is less than or equal to block_size. The default value 0 means that the minimum block size is determined automatically depending on the number of elements in the range divided by the number of available cores.