Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / range / doc / html / range / reference / algorithms / numeric / accumulate.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>accumulate</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../../../index.html" title="Chapter&#160;1.&#160;Range 2.0">
8 <link rel="up" href="../numeric.html" title="Numeric algorithms">
9 <link rel="prev" href="../numeric.html" title="Numeric algorithms">
10 <link rel="next" href="adjacent_difference.html" title="adjacent_difference">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="../numeric.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="adjacent_difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="range.reference.algorithms.numeric.accumulate"></a><a class="link" href="accumulate.html" title="accumulate">accumulate</a>
28 </h5></div></div></div>
29 <h6>
30 <a name="range.reference.algorithms.numeric.accumulate.h0"></a>
31             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.prototype"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.prototype">Prototype</a>
32           </h6>
33 <p>
34 </p>
35 <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
36     <span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span>
37     <span class="keyword">class</span> <span class="identifier">Value</span>
38     <span class="special">&gt;</span>
39 <span class="identifier">Value</span> <span class="identifier">accumulate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">source_rng</span><span class="special">,</span>
40                  <span class="identifier">Value</span> <span class="identifier">init</span><span class="special">);</span>
41
42 <span class="keyword">template</span><span class="special">&lt;</span>
43     <span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span>
44     <span class="keyword">class</span> <span class="identifier">Value</span><span class="special">,</span>
45     <span class="keyword">class</span> <span class="identifier">BinaryOperation</span>
46     <span class="special">&gt;</span>
47 <span class="identifier">Value</span> <span class="identifier">accumulate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">source_rng</span><span class="special">,</span>
48                  <span class="identifier">Value</span> <span class="identifier">init</span><span class="special">,</span>
49                  <span class="identifier">BinaryOperation</span> <span class="identifier">op</span><span class="special">);</span>
50 </pre>
51 <p>
52           </p>
53 <h6>
54 <a name="range.reference.algorithms.numeric.accumulate.h1"></a>
55             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.description"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.description">Description</a>
56           </h6>
57 <p>
58             <code class="computeroutput"><span class="identifier">accumulate</span></code> is a generalisation
59             of summation. It computes a binary operation (<code class="computeroutput"><span class="keyword">operator</span><span class="special">+</span></code> in the non-predicate version) of <code class="computeroutput"><span class="identifier">init</span></code> and all of the elements in <code class="computeroutput"><span class="identifier">rng</span></code>.
60           </p>
61 <p>
62             The return value is the resultant value of the above algorithm.
63           </p>
64 <h6>
65 <a name="range.reference.algorithms.numeric.accumulate.h2"></a>
66             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.definition"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.definition">Definition</a>
67           </h6>
68 <p>
69             Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">numeric</span><span class="special">.</span><span class="identifier">hpp</span></code>
70           </p>
71 <h6>
72 <a name="range.reference.algorithms.numeric.accumulate.h3"></a>
73             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.requirements"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.requirements">Requirements</a>
74           </h6>
75 <h6>
76 <a name="range.reference.algorithms.numeric.accumulate.h4"></a>
77             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.for_the_first_version"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.for_the_first_version">For
78             the first version</a>
79           </h6>
80 <div class="orderedlist"><ol class="orderedlist" type="1">
81 <li class="listitem">
82                 <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
83                 a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
84                 Pass Range</a> Concept.
85               </li>
86 <li class="listitem">
87                 <code class="computeroutput"><span class="identifier">Value</span></code> is a model
88                 of the <code class="computeroutput"><span class="identifier">AssignableConcept</span></code>.
89               </li>
90 <li class="listitem">
91                 An <code class="computeroutput"><span class="keyword">operator</span><span class="special">+</span></code>
92                 is defined for a left-hand operand of type <code class="computeroutput"><span class="identifier">Value</span></code>
93                 and a right-hand operand of the <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>
94                 value type.
95               </li>
96 <li class="listitem">
97                 The return type of the above operator is convertible to <code class="computeroutput"><span class="identifier">Value</span></code>.
98               </li>
99 </ol></div>
100 <h6>
101 <a name="range.reference.algorithms.numeric.accumulate.h5"></a>
102             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.for_the_second_version"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.for_the_second_version">For
103             the second version</a>
104           </h6>
105 <div class="orderedlist"><ol class="orderedlist" type="1">
106 <li class="listitem">
107                 <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
108                 a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
109                 Pass Range</a> Concept.
110               </li>
111 <li class="listitem">
112                 <code class="computeroutput"><span class="identifier">Value</span></code> is a model
113                 of the <code class="computeroutput"><span class="identifier">AssignableConcept</span></code>.
114               </li>
115 <li class="listitem">
116                 <code class="computeroutput"><span class="identifier">BinaryOperation</span></code> is
117                 a model of the <code class="computeroutput"><span class="identifier">BinaryFunctionConcept</span></code>.
118               </li>
119 <li class="listitem">
120                 <code class="computeroutput"><span class="identifier">Value</span></code> is convertible
121                 to <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>'s
122                 first argument type.
123               </li>
124 <li class="listitem">
125                 <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>'s
126                 value type is convertible to <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>'s
127                 second argument type.
128               </li>
129 <li class="listitem">
130                 The return type of <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>
131                 is convertible to <code class="computeroutput"><span class="identifier">Value</span></code>.
132               </li>
133 </ol></div>
134 <h6>
135 <a name="range.reference.algorithms.numeric.accumulate.h6"></a>
136             <span class="phrase"><a name="range.reference.algorithms.numeric.accumulate.complexity"></a></span><a class="link" href="accumulate.html#range.reference.algorithms.numeric.accumulate.complexity">Complexity</a>
137           </h6>
138 <p>
139             Linear. Exactly <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">source_rng</span><span class="special">)</span></code>.
140           </p>
141 </div>
142 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
143 <td align="left"></td>
144 <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2010 Thorsten Ottosen,
145       Neil Groves<p>
146         Distributed under the Boost Software License, Version 1.0. (See accompanying
147         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
148       </p>
149 </div></td>
150 </tr></table>
151 <hr>
152 <div class="spirit-nav">
153 <a accesskey="p" href="../numeric.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="adjacent_difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
154 </div>
155 </body>
156 </html>