File: reduce.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (35 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    hi(reduce)
    itemization(
    it() Header file: tt(<numeric>)
    it() Function prototypes:
        itemization(
        itt(Type reduce([ExecPol,] InputIterator first, InputIterator last);)
        itt(Type reduce([ExecPol,] InputIterator first, InputIterator last, 
                    Type init);)
        itt(Type reduce([ExecPol,] InputIterator first, InputIterator last,
                BinaryOperation op);) 
        itt(Type reduce([ExecPol,] InputIterator first, InputIterator last,
                Type init, BinaryOperation op);)
        )
    it() Description:
        This algorithm acts like tt(accumulate)
(cf. link(accumulate)(ACCU)), but the algorithm requires that the used
operator is both associative and commutative: regrouping and rearranging the
elements in any order may not affect the final outcome. E.g., the numeric
addition operator satisfies both requirements.
        itemization(
        it() The first prototype: ti(operator+) is applied to the elements in
the range rangett(first, last), returning the resulting sum.
        it() The second prototype: the binary operator tt(op) is applied to
the initial value tt(init) (lhs argument) and, respectively, the elements from
the iterator range rangett(first, last). The resulting sum value is returned.
        it() The last two prototypes act like, respectively, the first two
prototypes but instead of using tt(operator+) the binary operator tt(op) is
used, receiving the variable that's eventually returned from the function as
its lhs argument and the elements in the iterator range as its rhs argument,
assigning the operator's returned values to the variable that's eventually
returned. 
        )
        it() Example:
        verbinclude(-a examples/reduce.cc)
    )