auto-sync

This commit is contained in:
rusEfi 2015-03-27 22:08:14 -05:00
parent f0cb558733
commit f17a25641a
1 changed files with 15 additions and 3 deletions

View File

@ -34,9 +34,10 @@ class cyclic_buffer
public:
void add(T value);
int get(int index);
T get(int index);
T sum(int length);
void setSize(int size);
int getSize();
void clear();
private:
@ -108,8 +109,19 @@ void cyclic_buffer<T>::setSize(int size) {
}
template<typename T>
int cyclic_buffer<T>::get(int index) {
return 0;
int cyclic_buffer<T>::getSize() {
return size;
}
template<typename T>
T cyclic_buffer<T>::get(int index) {
while (index < 0) {
index += size;
}
while (index >= size) {
index -= size;
}
return elements[index];
}
template<typename T>