Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
prosilica
rolling_sum.h
Go to the documentation of this file.
1
#ifndef ROLLING_SUM_H
2
#define ROLLING_SUM_H
3
4
#include <boost/circular_buffer.hpp>
5
6
// Boost.Accumulators' rolling_sum is in 1.38 :(
7
template
<
typename
T>
8
class
RollingSum
9
{
10
public
:
11
RollingSum
(
size_t
capacity)
12
:
buffer_
(capacity),
sum_
(0)
13
{
14
buffer_
.push_back(0);
15
}
16
17
void
add
(T sample)
18
{
19
sum_
+= sample;
20
sum_
-=
buffer_
[0];
21
buffer_
.push_back(sample);
22
}
23
24
T
sum
()
25
{
26
return
sum_
;
27
}
28
29
private
:
30
boost::circular_buffer<T>
buffer_
;
31
T
sum_
;
32
};
33
34
#endif
RollingSum::add
void add(T sample)
Definition:
rolling_sum.h:17
RollingSum::RollingSum
RollingSum(size_t capacity)
Definition:
rolling_sum.h:11
RollingSum::sum
T sum()
Definition:
rolling_sum.h:24
RollingSum::buffer_
boost::circular_buffer< T > buffer_
Definition:
rolling_sum.h:30
RollingSum
Definition:
rolling_sum.h:8
RollingSum::sum_
T sum_
Definition:
rolling_sum.h:31
prosilica_camera
Author(s): Maintained by William Woodall - wwoodall@willowgarage.com, Contributions by Allison Thackston - allison.thackston@nasa.gov
autogenerated on Mon Jun 10 2019 14:20:19