2012-05-14 16:11:09 +10:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-05-14 16:11:09 +10:00
|
|
|
*
|
|
|
|
* Copyright 2010 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
2021-04-14 15:35:49 +10:00
|
|
|
#pragma once
|
2012-05-14 16:11:09 +10:00
|
|
|
|
2018-03-22 16:10:06 +11:00
|
|
|
#include <iosfwd>
|
2012-05-14 16:11:09 +10:00
|
|
|
|
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
namespace cruft {
|
2012-05-14 16:11:09 +10:00
|
|
|
namespace stats {
|
|
|
|
// Undefined until at least one value has been added.
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct accumulator {
|
|
|
|
accumulator ();
|
|
|
|
|
2012-08-07 18:34:36 +10:00
|
|
|
void reset (void);
|
|
|
|
|
2012-05-14 16:11:09 +10:00
|
|
|
void add (T);
|
|
|
|
void add (const accumulator<T> &);
|
|
|
|
|
2012-05-15 16:04:06 +10:00
|
|
|
size_t count;
|
|
|
|
|
2012-05-14 16:11:09 +10:00
|
|
|
T min;
|
|
|
|
T max;
|
2012-05-15 16:04:06 +10:00
|
|
|
T sum;
|
2012-05-14 16:11:09 +10:00
|
|
|
|
|
|
|
T range (void) const;
|
2012-05-15 16:04:06 +10:00
|
|
|
T mean (void) const;
|
2012-05-14 16:11:09 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
std::ostream& operator<< (std::ostream&, const accumulator<T>&);
|
|
|
|
}
|
2021-04-14 15:35:49 +10:00
|
|
|
}
|