5#include <initializer_list>
29 bufferIn_ = bufferOut_ = 0;
33 while((
readPtr !=
other.bufferIn_) && (bufferIn_ < bufferSize_))
45 void Clear() { bufferIn_ = bufferOut_ = 0; }
54 if(bufferIn_ >= bufferSize_)
55 bufferIn_ -= bufferSize_;
82 int idx = bufferIn_ - 1;
94 int idx = bufferIn_ - 1;
107 const auto result = buffer_[bufferOut_];
109 if(bufferOut_ >= bufferSize_)
110 bufferOut_ -= bufferSize_;
121 return buffer_[bufferOut_];
130 return buffer_[bufferOut_];
136 auto idx = bufferOut_;
137 while(
idx != bufferIn_)
142 if(
idx >= bufferSize_)
152 size_t idx = bufferOut_;
153 while(
idx != bufferIn_)
158 if(
idx >= bufferSize_)
165 bool IsEmpty()
const {
return bufferIn_ == bufferOut_; }
195 (*
this)[
i] = (*this)[
i - 1];
208 size_t index = bufferOut_ +
idx;
209 if(index >= bufferSize_)
210 index -= bufferSize_;
220 if(index >= bufferSize_)
221 index -= bufferSize_;
264 size_t index = bufferOut_ +
idx;
265 if(index >= bufferSize_)
266 index -= bufferSize_;
267 return buffer_[index];
277 size_t index = bufferOut_ +
idx;
278 if(index >= bufferSize_)
279 index -= bufferSize_;
280 return buffer_[index];
291 const size_t bufferSize_;
297template <
typename T,
size_t capacity>
311 template <
size_t otherCapacity>
318 template <
size_t otherCapacity>
326 T buffer_[capacity + 1];
T & Front()
Definition FIFO.h:116
bool PushBack(const T &elementToAdd)
Definition FIFO.h:49
T PopFront()
Definition FIFO.h:101
bool Contains(const T &element)
Definition FIFO.h:134
FIFOBase(T *buffer, size_t bufferSize)
Definition FIFO.h:14
const T & Front() const
Definition FIFO.h:125
const T & operator[](size_t idx) const
Definition FIFO.h:271
size_t GetNumElements() const
Definition FIFO.h:171
void Clear()
Definition FIFO.h:45
bool Insert(size_t idx, const T &element)
Definition FIFO.h:180
T & Back()
Definition FIFO.h:77
bool Remove(size_t idx)
Definition FIFO.h:203
~FIFOBase()
Definition FIFO.h:42
const T & Back() const
Definition FIFO.h:89
FIFOBase< T > & operator=(const FIFOBase< T > &other)
Definition FIFO.h:27
size_t RemoveAllEqualTo(const T &element)
Definition FIFO.h:237
FIFOBase(T *buffer, size_t bufferSize, std::initializer_list< T > valuesToAdd)
Definition FIFO.h:19
int PushBack(std::initializer_list< T > valuesToAdd)
Definition FIFO.h:62
bool IsFull() const
Definition FIFO.h:168
size_t CountEqualTo(const T &element)
Definition FIFO.h:149
T & operator[](size_t idx)
Definition FIFO.h:258
size_t GetCapacity() const
Definition FIFO.h:284
bool IsEmpty() const
Definition FIFO.h:165
FIFO(std::initializer_list< T > valuesToAdd)
Definition FIFO.h:305
FIFO< T, capacity > & operator=(const FIFO< T, otherCapacity > &other)
Definition FIFO.h:319
FIFO(const FIFO< T, otherCapacity > &other)
Definition FIFO.h:312
FIFO()
Definition FIFO.h:302
Definition leddriver.h:33
Hardware defines and helpers for daisy field platform.
Definition index.h:2