Parallel count operation.
More...
Parallel count operation.
template<typename RAI , typename ValueType >
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
-
- 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
-
RAI | Random access iterator |
ValueType | Type of value that is compared to the elements in the range using the operator== . |
- Parameters
-
[in] | first | Random access iterator pointing to the first element of the range |
[in] | last | Random access iterator pointing to the last plus one element of the range |
[in] | value | Value that the elements in the range are compared to using operator== |
[in] | policy | embb::mtapi::ExecutionPolicy for the counting algorithm |
[in] | block_size | Lower 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 >
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
-
- 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
-
RAI | Random access iterator |
ComparisonFunction | Unary 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] | first | Random 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] | comparison | Unary predicate used to test the elements in the range. Elements for which comparison returns true are counted. |
[in] | policy | embb::mtapi::ExecutionPolicy for the counting algorithm |
[in] | block_size | Lower 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. |