AFF --- A container for numbers (array) by Friederich and Forbriger.
avg.h
Go to the documentation of this file.
1
36
// include guard
37
#ifndef AFF_AVG_H_VERSION
38
39
#define AFF_AVG_H_VERSION \
40
"AFF_AVG_H V1.1 "
41
42
43
#include<
aff/lib/collector.h
>
44
45
namespace
aff
{
46
47
namespace
func {
48
49
namespace
util {
50
58
template
<
class
C>
59
class
Extractavg
{
60
typedef
typename
C::Tcoc
Tcont
;
61
typedef
typename
C::Tvalue
Tvalue
;
62
public
:
63
typedef
Tvalue
Tretval
;
65
Extractavg
(
const
Tcont
& c):
Msum
(0),
Mn
(0) { }
67
void
operator()
(
const
Tvalue
& v) {
Msum
+=v; ++
Mn
; }
69
Tretval
result
()
const
{
return
(
Msum
/
Tvalue
(
Mn
)); }
70
private
:
71
Tvalue
Msum
;
72
int
Mn
;
73
};
// class Extractavg
74
75
}
// namespace util
76
77
/*----------------------------------------------------------------------*/
78
89
template
<
class
C>
90
typename
C::Tvalue
avg
(
const
C& c)
91
{
92
return
(aff::func::util::collect<C, aff::func::util::Extractavg>(c));
93
}
// avg()
94
95
}
// namespace func
96
97
}
// namespace aff
98
99
#endif // AFF_AVG_H_VERSION (includeguard)
100
101
/* ----- END OF avg.h ----- */
aff
Root namespace of library.
Definition:
array.h:148
collector.h
collect values (prototypes)
aff::func::avg
C::Tvalue avg(const C &c)
Definition:
avg.h:90
aff::func::util::Extractavg::Tretval
Tvalue Tretval
Definition:
avg.h:63
aff::func::util::Extractavg::Tcont
C::Tcoc Tcont
Definition:
avg.h:60
aff::func::util::Extractavg::result
Tretval result() const
return result of operation
Definition:
avg.h:69
aff::func::util::Extractavg::operator()
void operator()(const Tvalue &v)
collect another value
Definition:
avg.h:67
aff::func::util::Extractavg::Tvalue
C::Tvalue Tvalue
Definition:
avg.h:61
aff::func::util::Extractavg::Mn
int Mn
Definition:
avg.h:72
aff::func::util::Extractavg
Definition:
avg.h:59
aff::func::util::Extractavg::Msum
Tvalue Msum
Definition:
avg.h:71
aff::func::util::Extractavg::Extractavg
Extractavg(const Tcont &c)
initialize member data
Definition:
avg.h:65
functions
avg.h
Generated on Mon Aug 21 2023 17:36:08 for AFF --- A container for numbers (array) by Friederich and Forbriger. by
1.8.14