tfel
Loading...
Searching...
No Matches
tfel::fsalgo::accumulate< N > Class Template Reference

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>

Static Public Member Functions

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)

Detailed Description

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
Nnumber 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

Member Function Documentation

◆ exe() [1/2]

template<unsigned int N>
template<typename InputIterator, typename T>
T tfel::fsalgo::accumulate< N >::exe ( InputIterator p,
const T init )
inlinestatic
Template Parameters
InputIteratoriterator of the sequence to be summed
Ttype of the result
Parameters
[in]piterator to the first element of the sequence
[in]initinitial 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>
T tfel::fsalgo::accumulate< N >::exe ( InputIterator p,
const T init,
BinaryFunction binary_op )
inlinestatic
Template Parameters
InputIteratoriterator of the sequence to be operated on
Ttype of the result
BinaryFunctionfunction doing the operation
Parameters
[in]piterator to the first element of the sequence
[in]initinitial value
[in]binary_opfunction 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: