GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
seq/reduce.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_SEQ_REDUCE_H
22 #define GRPPI_SEQ_REDUCE_H
23 
24 #include "sequential_execution.h"
25 
26 namespace grppi {
27 
48 template <typename InputIt, typename Identity, typename Combiner>
49 auto reduce(sequential_execution & ex, InputIt first, InputIt last,
50  Identity identity,
51  Combiner && combine_op)
52 {
53  auto result = identity;
54  while (first != last) {
55  result = combine_op(result, *first);
56  first++;
57  }
58  return result;
59 }
60 
66 }
67 
68 #endif
Definition: callable_traits.h:24
Sequential execution policy.
Definition: sequential_execution.h:31
auto reduce(parallel_execution_native &ex, InputIt first, InputIt last, Identity identity, Combiner &&combine_op)
Invoke Reduce pattern with identity value on a data sequence with parallel native execution...
Definition: native/reduce.h:51