5#include <initializer_list>
34 const auto numCopy = (
other.GetNumElements() < bufferSize_)
35 ?
other.GetNumElements()
39 bufferHead_ =
other.GetNumElements();
80 return buffer_[--bufferHead_];
85 void Clear() { bufferHead_ = 0; }
97 if(
idx >= bufferHead_)
102 buffer_[
i] = buffer_[
i + 1];
114 int idx = bufferHead_ - 1;
122 if(
decltype(bufferHead_)(
idx) == bufferHead_)
134 if(bufferHead_ >= bufferSize_)
136 if(
idx > bufferHead_)
138 if(
idx == bufferHead_)
140 buffer_[bufferHead_++] =
item;
146 buffer_[
i + 1] = buffer_[
i];
156 int idx = bufferHead_ - 1;
170 int idx = bufferHead_ - 1;
181 bool IsEmpty()
const {
return bufferHead_ == 0; }
184 bool IsFull()
const {
return bufferHead_ == bufferSize_; }
194 const size_t bufferSize_;
200template <
typename T,
size_t capacity>
214 template <
size_t otherCapacity>
222 template <
size_t otherCapacity>
Definition leddriver.h:33
const T & operator[](uint32_t idx) const
Definition Stack.h:92
bool Remove(uint32_t idx)
Definition Stack.h:95
~StackBase()
Definition Stack.h:44
bool PushBack(const T &elementToAdd)
Definition Stack.h:48
int RemoveAllEqualTo(const T &element)
Definition Stack.h:111
bool Insert(uint32_t idx, const T &item)
Definition Stack.h:132
size_t GetNumElements() const
Definition Stack.h:187
StackBase(T *buffer, size_t bufferSize)
Definition Stack.h:14
StackBase< T > & operator=(const StackBase< T > &other)
Definition Stack.h:29
T PopBack()
Definition Stack.h:74
size_t GetCapacity() const
Definition Stack.h:190
T & operator[](uint32_t idx)
Definition Stack.h:89
int PushBack(std::initializer_list< T > valuesToAdd)
Definition Stack.h:59
bool IsEmpty() const
Definition Stack.h:181
bool Contains(const T &element)
Definition Stack.h:154
size_t CountEqualTo(const T &element)
Definition Stack.h:167
void Clear()
Definition Stack.h:85
StackBase(T *buffer, size_t bufferSize, std::initializer_list< T > valuesToAdd)
Definition Stack.h:19
bool IsFull() const
Definition Stack.h:184
Stack()
Definition Stack.h:205
Stack(const Stack< T, otherCapacity > &other)
Definition Stack.h:215
Stack(std::initializer_list< T > valuesToAdd)
Definition Stack.h:208
Stack< T, capacity > & operator=(const Stack< T, otherCapacity > &other)
Definition Stack.h:223
Hardware defines and helpers for daisy field platform.
Definition index.h:2