From c0dbf6936de79ce6c60fca640df722557b9270d6 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 7 Aug 2012 18:34:36 +1000 Subject: [PATCH] Expose a reset method for stats accumulator --- stats.cpp | 19 +++++++++++++------ stats.hpp | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/stats.cpp b/stats.cpp index 58e85d01..92acfe77 100644 --- a/stats.cpp +++ b/stats.cpp @@ -24,12 +24,19 @@ template -util::stats::accumulator::accumulator (): - count (0), - min (std::numeric_limits::max ()), - max (std::numeric_limits::min ()), - sum (0) -{ ; } +util::stats::accumulator::accumulator () { + reset (); +} + + +template +void +util::stats::accumulator::reset (void) { + count = 0; + min = std::numeric_limits::max (); + max = std::numeric_limits::min (); + sum = 0; +} template diff --git a/stats.hpp b/stats.hpp index 5323b351..e9d187a1 100644 --- a/stats.hpp +++ b/stats.hpp @@ -31,6 +31,8 @@ namespace util { struct accumulator { accumulator (); + void reset (void); + void add (T); void add (const accumulator &);