Overte C++ Documentation
SimpleAverage.h
1
//
2
// Created by Bradley Austin Davis on 2015/07/01.
3
// Copyright 2013 High Fidelity, Inc.
4
//
5
// Distributed under the Apache License, Version 2.0.
6
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7
//
8
9
#pragma once
10
#ifndef hifi_SimpleAverage_h
11
#define hifi_SimpleAverage_h
12
13
template
<
typename
T>
14
class
SimpleAverage {
15
public
:
16
void
update(T sample) {
17
_sum += sample;
18
++_count;
19
}
20
void
reset() {
21
_sum = 0;
22
_count = 0;
23
}
24
25
int
getCount()
const
{
return
_count; };
26
T getAverage()
const
{
return
_sum / (T)_count; };
27
28
private
:
29
int
_count;
30
T _sum;
31
};
32
33
#endif
libraries
shared
src
SimpleAverage.h
Generated by
1.9.1