Skip to content

Instantly share code, notes, and snippets.

@garethlewin
Created July 13, 2013 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethlewin/5988789 to your computer and use it in GitHub Desktop.
Save garethlewin/5988789 to your computer and use it in GitHub Desktop.
template <class values_t>
class DurationBasedStatsContainer
{
public:
typedef std::list<std::pair<std::chrono::high_resolution_clock::time_point, typename values_t>> valueList_t;
typedef std::chrono::milliseconds freq_t;
DurationBasedStatsContainer(freq_t maxDuration);
void push(values_t&& value);
values_t max();
values_t min();
values_t average();
valueList_t::iterator begin() { return mValues.begin(); }
valueList_t::iterator end() { return mValues.end(); }
valueList_t::iterator cbegin() const { return mValues.cbegin(); }
valueList_t::iterator cend() const { return mValues.cend(); }
private:
freq_t mMaxDuration;
valueList_t mValues;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment