30 #ifndef MATH_UTIL_GENERIC_RING_BUFFER_H_ 31 #define MATH_UTIL_GENERIC_RING_BUFFER_H_ 35 #define GEN_RING_BUFF_DEFAULT_NUM_ELEMENTS 16 100 virtual T*
get(
int i = 0)
const 104 return (&
HEAD[j].Data);
113 return (&
HEAD[i].Data);
130 return (&
HEAD[j].Data);
146 if (this->
size() == 0)
172 temp =
new ctr[std::max(2, NumElements2Alloc)];
207 int Num2Copy = std::min(NumElements, MaxNum2Copy);
208 if (Num2Copy !=NumElements)
216 for (
int i = 0; i < Num2Copy; i++)
218 dest[i].
Data = *(this->
get(i));
225 assert(NumElements <= MaxNumElements);
226 loadPtr->
Data = newElem;
227 if (NumElements >= MaxNumElements)
241 loadPtr = loadPtr->
next;
246 consumePtr = consumePtr->
next;
251 HEAD =
new ctr[std::max(NumElems, 2)];
252 TAIL = HEAD+NumElems;
255 MaxNumElements = NumElems;
264 j = (i+1)%MaxNumElements;
265 k = (i-1)%MaxNumElements;
266 HEAD[i].
next = &HEAD[j];
267 HEAD[i].
prev = &HEAD[k];
281 this->NumElements = 0;
288 this->
load(*(src[i]));
294 #endif // MATH_UTIL_GENERIC_RING_BUFFER_H_
T * getTail(int i=0) const
void copyRB(GenRingBuffer< T > &src)
GenRingBuffer(const GenRingBuffer< T > &src)
void realloc_mem(int NumElements2Alloc)
void push(const T &newElem)
bool copy_elems(ctr *dest, int MaxNum2Copy)
void load(const T &newElem)
void ResizeBuffer(int newSize)
GenRingBuffer< T > & operator=(const GenRingBuffer< T > &src)
ctr * alloc_mem(int NumElems)
#define GEN_RING_BUFF_DEFAULT_NUM_ELEMENTS
virtual T * operator[](int i)
GenRingBuffer(int NumElements2Alloc)