11 #ifndef TLX_ALGORITHM_EXCLUSIVE_SCAN_HEADER 12 #define TLX_ALGORITHM_EXCLUSIVE_SCAN_HEADER 28 template <
typename InputIterator,
typename OutputIterator,
29 typename T,
typename BinaryOperation = std::plus<T> >
31 OutputIterator result, T init,
32 BinaryOperation binary_op = BinaryOperation()) {
35 typename std::iterator_traits<InputIterator>::value_type value =
36 binary_op(init, *first);
38 while (++first != last) {
39 value = binary_op(value, *first);
51 #endif // !TLX_ALGORITHM_EXCLUSIVE_SCAN_HEADER
OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op=BinaryOperation())
Computes an exclusive prefix sum operation using binary_op the range [first, last), using init as the initial value, and writes the results to the range beginning at result.