Returns `Statistics` for the given `TimeSeries`, or `None` if the `TimeSeries` has less then 2 datapoints. TODO(dhamon): Consider adding a histogram abstraction for better performance. Remove this specification once we can construct directly from `TimeSeries ::Value`, e.g., by using an iterator adaptor, see https://www.boost.org/doc/libs/1_51_0/libs/range/doc/html/range/reference/adaptors/refe
| 41 | // `TimeSeries<T>::Value`, e.g., by using an iterator adaptor, see |
| 42 | // https://www.boost.org/doc/libs/1_51_0/libs/range/doc/html/range/reference/adaptors/reference/map_values.html // NOLINT(whitespace/line_length) |
| 43 | static Option<Statistics<T>> from(const TimeSeries<T>& timeseries) |
| 44 | { |
| 45 | std::vector<typename TimeSeries<T>::Value> values_ = timeseries.get(); |
| 46 | |
| 47 | std::vector<T> values; |
| 48 | values.reserve(values_.size()); |
| 49 | |
| 50 | foreach (const typename TimeSeries<T>::Value& value, values_) { |
| 51 | values.push_back(value.data); |
| 52 | } |
| 53 | |
| 54 | return from(std::move(values)); |
| 55 | } |
| 56 | |
| 57 | // Returns `Statistics` for the given container, or `None` if the container |
| 58 | // has less then 2 datapoints. The container is represented as a pair of |