Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:23

0001 /*
0002    Copyright (c) Marshall Clow 2017.
0003 
0004    Distributed under the Boost Software License, Version 1.0. (See accompanying
0005    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 /// \file  transform_exclusive_scan.hpp
0009 /// \brief ????
0010 /// \author Marshall Clow
0011 
0012 #ifndef BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP
0013 #define BOOST_ALGORITHM_TRANSFORM_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 /// \fn transform_exclusive_scan ( InputIterator first, InputIterator last, OutputIterator result, BinaryOperation bOp, UnaryOperation uOp, T init )
0026 /// \brief Transforms elements from the input range with uOp and then combines
0027 /// those transformed elements with bOp such that the n-1th element and the nth
0028 /// element are combined. Exclusivity means that the nth element is not
0029 /// included in the nth combination.
0030 /// \return The updated output iterator
0031 ///
0032 /// \param first  The start of the input sequence
0033 /// \param last   The end of the input sequence
0034 /// \param result The output iterator to write the results into
0035 /// \param bOp    The operation for combining transformed input elements
0036 /// \param uOp    The operation for transforming input elements
0037 /// \param init   The initial value
0038 ///
0039 /// \note This function is part of the C++17 standard library
0040 template<class InputIterator, class OutputIterator, class T,
0041          class BinaryOperation, class UnaryOperation>
0042 OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
0043                                         OutputIterator result, T init,
0044                                         BinaryOperation bOp, UnaryOperation uOp)
0045 {
0046     if (first != last)
0047     {
0048         T saved = init;
0049         do
0050         {
0051             init = bOp(init, uOp(*first));
0052             *result = saved;
0053             saved = init;
0054             ++result;
0055         } while (++first != last);
0056     }
0057     return result;
0058 }
0059 
0060 }} // namespace boost and algorithm
0061 
0062 #endif // BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP