File indexing completed on 2025-01-18 09:28:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP
0013 #define BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP
0014
0015 #include <functional> // for std::plus
0016 #include <iterator> // for std::iterator_traits
0017
0018 #include <boost/config.hpp>
0019 #include <boost/range/begin.hpp>
0020 #include <boost/range/end.hpp>
0021 #include <boost/range/value_type.hpp>
0022
0023 namespace boost { namespace algorithm {
0024
0025 template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
0026 OutputIterator exclusive_scan(InputIterator first, InputIterator last,
0027 OutputIterator result, T init, BinaryOperation bOp)
0028 {
0029 if (first != last)
0030 {
0031 T saved = init;
0032 do
0033 {
0034 init = bOp(init, *first);
0035 *result = saved;
0036 saved = init;
0037 ++result;
0038 } while (++first != last);
0039 }
0040 return result;
0041 }
0042
0043 template<class InputIterator, class OutputIterator, class T>
0044 OutputIterator exclusive_scan(InputIterator first, InputIterator last,
0045 OutputIterator result, T init)
0046 {
0047 typedef typename std::iterator_traits<InputIterator>::value_type VT;
0048 return boost::algorithm::exclusive_scan(first, last, result, init, std::plus<VT>());
0049 }
0050
0051 }}
0052
0053 #endif