prime/include/Kyoto/TAverage.hpp

42 lines
835 B
C++
Raw Normal View History

2022-10-02 21:53:28 +00:00
#ifndef _TAVERAGE_HPP
#define _TAVERAGE_HPP
#include "types.h"
#include "rstl/optional_object.hpp"
#include "rstl/vector.hpp"
template < typename T >
class TAverage : rstl::vector< T > {
public:
TAverage() {}
TAverage(int capacity, const T& value);
void AddValue(const T& value);
2022-10-04 00:00:46 +00:00
rstl::optional_object< T > GetAverage() const {
if (empty()) {
return rstl::optional_object_null();
} else {
return GetAverageValue(data(), size());
}
}
2022-10-02 21:53:28 +00:00
};
template < typename T >
TAverage< T >::TAverage(int capacity, const T& value) {
resize(capacity, value);
}
template < typename T >
void TAverage< T >::AddValue(const T& value) {
2022-10-04 00:00:46 +00:00
if (size() == capacity()) {
// TODO ?
x4_count -= 1;
}
2022-10-04 00:00:46 +00:00
insert(begin(), value);
}
2022-10-04 00:00:46 +00:00
template < typename T >
T GetAverageValue(const T* ptr, int count); // TODO
2022-10-02 21:53:28 +00:00
#endif