2022-04-10 00:17:06 +00:00
|
|
|
#ifndef _TRESERVEDAVERAGE_HPP
|
|
|
|
#define _TRESERVEDAVERAGE_HPP
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include "rstl/optional_object.hpp"
|
|
|
|
#include "rstl/reserved_vector.hpp"
|
|
|
|
|
2022-09-05 04:01:13 +00:00
|
|
|
template < typename T, int N >
|
2022-04-10 00:17:06 +00:00
|
|
|
class TReservedAverage : rstl::reserved_vector< T, N > {
|
|
|
|
public:
|
|
|
|
TReservedAverage(const T& value) {
|
|
|
|
// resize(value, N); TODO
|
|
|
|
}
|
|
|
|
void AddValue(const T& value) {
|
|
|
|
push_back(value);
|
2022-09-05 04:01:13 +00:00
|
|
|
for (int i = size() - 1; i > 0; --i) {
|
2022-04-10 00:17:06 +00:00
|
|
|
operator[](i) = operator[](i - 1);
|
|
|
|
}
|
|
|
|
operator[](0) = value;
|
|
|
|
}
|
|
|
|
rstl::optional_object< T > GetAverage() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|