Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

accumulate()

Module:  Standard C++ Library   Library:  Numerics


Function

Local Index

No Entries

Summary

A generalized numeric operation that accumulates all elements within a range into a single value

Synopsis

#include <numeric>

namespace std {
  template <class InputIterator, class T>
  T accumulate(InputIterator start,
               InputIterator finish,
               T init);

  template <class InputIterator,
            class T,
            class BinaryOperation>
  T accumulate(InputIterator start,
               InputIterator finish,
               T init,
               BinaryOperation binary_op);
}

Description

accumulate() applies a binary operation to init and each value in the range [start,finish). The result of each operation is returned in init. This process aggregates the result of performing the operation on every element of the sequence into a single value.

The accumulator acc is initialized with the value init and modified with acc = acc + *i or acc = binary_op(acc, *i) for each interator i, in order, in the range [start, finish).

Complexity

accumulate() performs exactly finish-start applications of the binary operation, operator+ by default.

Example

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 26.4.1



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.