auto-sync
This commit is contained in:
parent
f0cb558733
commit
f17a25641a
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue