accumulate computes the sum (or some other binary operation) of N elements of a container.
More...
#include </home/runner/work/tfel/tfel/include/TFEL/FSAlgorithm/accumulate.hxx>
|
| template<typename InputIterator, typename T> |
| static T | exe (InputIterator p, const T init) |
| template<class InputIterator, class T, class BinaryFunction> |
| static T | exe (InputIterator p, const T init, BinaryFunction binary_op) |
template<unsigned int N>
class tfel::fsalgo::accumulate< N >
accumulate computes the sum (or some other binary operation) of N elements of a container.
- Template Parameters
-
| N | number of elements to be summed. |
This documentation is mostly inspired from: http://www.sgi.com/tech/stl/transform.html
- See also
- accumulate.cxx for some elementary tests.
- Author
- Thomas Helfer
- Date
- 30/06/2006
◆ exe() [1/2]
template<unsigned int N>
template<typename InputIterator, typename T>
- Template Parameters
-
| InputIterator | iterator of the sequence to be summed |
| T | type of the result |
- Parameters
-
| [in] | p | iterator to the first element of the sequence |
| [in] | init | initial value |
- Returns
- result of the summation:
\[\displaystyle\mathrm{init}+\sum_{i=0}^{N-1}*(p+i)\]
- Precondition
- InputIterator is a model of Input Iterator.
- T is a model of Assignable.
- If x is an object of type T and y is an object of InputIterator's value type, then x + y is defined.
- The return type of x + y is convertible to T.
◆ exe() [2/2]
template<unsigned int N>
template<class InputIterator, class T, class BinaryFunction>
- Template Parameters
-
| InputIterator | iterator of the sequence to be operated on |
| T | type of the result |
| BinaryFunction | function doing the operation |
- Parameters
-
| [in] | p | iterator to the first element of the sequence |
| [in] | init | initial value |
| [in] | binary_op | function doing the operation |
- Returns
- result of the operation :
\[\displaystyle\mathrm{Op}\left(*(p+N-1),\ldots,\mathrm{Op}\left(*p,\mathrm{init}\right)\ldots\right)\]
- Precondition
- InputIterator is a model of Input Iterator.
- T is a model of Assignable.
- BinaryFunction is a model of Binary Function.
- The value type of InputIterator is convertible to BinaryFunction's first argument type.
- T is convertible to BinaryFunction's second argument type.
- BinaryFunction's return type is convertible to T.
The documentation for this class was generated from the following file: