Taiko-Nijiiro-Analog-IOBoard/Firmware/cache.h
KIT! 41cd538253 Hard fork initial commit
This commit contains the kicad files for the PCB, the updated firmware for this new pcb design.
2024-04-30 17:11:24 +02:00

31 lines
964 B
C++

/***************************************************************
* *
* Taiko Sanro - Arduino *
* Cache data structure *
* *
* Chris *
* wisaly@gmail.com *
* *
***************************************************************/
#ifndef CACHE_H
#define CACHE_H
template <class T, int L>
class Cache {
public:
Cache() { memset(data_, 0, sizeof(data_)); }
inline void put(T value) {
current_ = (current_ + 1) % L;
data_[current_] = value;
}
inline T get(int offset = 0) const {
return data_[(current_ + offset) % L];
}
private:
T data_[L];
int current_ = 0;
};
#endif // CACHE_H