#include <errno.h>
#include <list>
#include <string>
+#include <cstdlib>
#include <boost/optional.hpp>
inline Time &subtract (const time_t t2) NOEXCEPT
{ return this->subtract (t2, 0L); };
- Time &scale (const time_t factor) NOEXCEPT;
+ Time &scale (const int64_t factor) NOEXCEPT;
+
+ Time ÷ (const int64_t divisor) NOEXCEPT;
friend int compare (const Time &t1, const Time &t2) NOEXCEPT;
{ return this->subtract (t2); }
inline Time
- operator* (const time_t factor) const NOEXCEPT
+ operator* (const int64_t factor) const NOEXCEPT
{ return Time (*this).scale (factor); }
inline Time &
- operator*= (const time_t factor) NOEXCEPT
+ operator*= (const int64_t factor) NOEXCEPT
{ return this->scale (factor); }
+ inline Time
+ operator/ (const int64_t divisor) const NOEXCEPT
+ { return Time (*this).divide (divisor); }
+
+ inline Time &
+ operator/= (const int64_t divisor) NOEXCEPT
+ { return this->divide (divisor); }
+
friend CONSTEXPR bool
operator== (const Time &t1, const Time &t2) NOEXCEPT;
operator- (const time_t t1, const Time &t2) NOEXCEPT
{ return Time (t1) - t2; }
+ inline Time
+ operator* (const time_t t1, const Time &t2) NOEXCEPT
+ { return t2 * t1; }
+
int compare (const Time &t1, const Time &t2) NOEXCEPT;
/*
const enum type::id id = type::real,
const enum type::variant var = type::dflt) NOEXCEPT;
+ template <typename ContT>
+ Time
+ mean (const ContT &data)
+ {
+ Time sum (0, 0);
+
+ if (data.size () == 0) {
+ return sum;
+ }
+
+ for (typename ContT::const_iterator it = data.begin ();
+ it != data.end (); ++it)
+ {
+ sum += *it;
+ };
+
+ return sum.divide (static_cast<int64_t> (data.size ()));
+ };
+
+ template <typename ContT>
+ Time
+ median (const ContT &data)
+ {
+ if (data.size () == 0) {
+ return zero ();
+ }
+ if (data.size () == 1) {
+ return *data.begin ();
+ }
+
+ std::vector<typename ContT::value_type> sorted;
+ std::copy (data.begin (), data.end (), std::back_inserter (sorted));
+ std::sort (sorted.begin (), sorted.end ());
+
+ return sorted [data.size () / 2];
+ };
+
} /* [namespace clock] */
} /* [namespace I2n] */