#include <CircularQueue.h>
Public Member Functions | |
CircularQueue (size_t size, T v) | |
Creates a circular queue with a specified size. | |
virtual | ~CircularQueue () |
T & | get (int position=0) const |
Returns a reference of an element in the queue from a specified position. | |
void | put (const T &elem) |
Puts new element at the tail of the queue. | |
void | moveMark (int steps) |
Moves the mark of the queue forward for specific number of steps. | |
T & | getFromMark (int position) const |
Returns a reference of an element in the queue from a calculated position. | |
void | reset (T v) |
void | putArray (double *arr, int len) |
Protected Attributes | |
size_t | _size |
unsigned | current |
unsigned | currentMark |
T * | entry |
A fixed size circular queue implementation.
Objects of type T are stored in the queue. The class T must have default constructor.
Definition at line 23 of file CircularQueue.h.
CircularQueue< T >::CircularQueue | ( | size_t | size, | |
T | v | |||
) | [inline] |
Creates a circular queue with a specified size.
The queue is initialized with size T() objects.
Definition at line 75 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::entry, and CircularQueue< T >::reset().
CircularQueue< T >::~CircularQueue | ( | ) | [inline, virtual] |
T & CircularQueue< T >::get | ( | int | position = 0 |
) | const [inline] |
Returns a reference of an element in the queue from a specified position.
position | The position of the returned element, counting from the head of the queue. The head has position 0. |
Definition at line 100 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::current, and CircularQueue< T >::entry.
Referenced by AnalogDelayObject::advance(), and AnalogDelayObject::getAnalogOutput().
void CircularQueue< T >::put | ( | const T & | elem | ) | [inline] |
Puts new element at the tail of the queue.
This effectively drops one element from the head, since the queue is circular and fixed size.
elem | reference to the element which copy is put in the queue. |
Definition at line 142 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::current, and CircularQueue< T >::entry.
Referenced by AnalogDelayObject::advance().
void CircularQueue< T >::moveMark | ( | int | steps | ) | [inline] |
Moves the mark of the queue forward for specific number of steps.
Definition at line 132 of file CircularQueue.h.
References CircularQueue< T >::_size, and CircularQueue< T >::currentMark.
Referenced by AnalogDelayObject::advanceCycle(), and AnalogDelayObject::putNewCycleValues().
T & CircularQueue< T >::getFromMark | ( | int | position | ) | const [inline] |
Returns a reference of an element in the queue from a calculated position.
position | The position of the wanted element, counting from the marked position. |
Definition at line 123 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::currentMark, and CircularQueue< T >::entry.
Referenced by AnalogDelayObject::getCycledAnalogOutput().
void CircularQueue< T >::reset | ( | T | v | ) | [inline] |
Definition at line 91 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::current, CircularQueue< T >::currentMark, and CircularQueue< T >::entry.
Referenced by CircularQueue< T >::CircularQueue(), and AnalogDelayObject::reset().
void CircularQueue< T >::putArray | ( | double * | arr, | |
int | len | |||
) | [inline] |
Definition at line 108 of file CircularQueue.h.
References CircularQueue< T >::_size, CircularQueue< T >::current, and CircularQueue< T >::entry.
Referenced by AnalogDelayObject::putNewCycleValues().
size_t CircularQueue< T >::_size [protected] |
Definition at line 67 of file CircularQueue.h.
Referenced by CircularQueue< T >::CircularQueue(), CircularQueue< T >::get(), CircularQueue< T >::getFromMark(), CircularQueue< T >::moveMark(), CircularQueue< T >::put(), CircularQueue< T >::putArray(), and CircularQueue< T >::reset().
unsigned CircularQueue< T >::current [protected] |
Definition at line 68 of file CircularQueue.h.
Referenced by CircularQueue< T >::get(), CircularQueue< T >::put(), CircularQueue< T >::putArray(), and CircularQueue< T >::reset().
unsigned CircularQueue< T >::currentMark [protected] |
Definition at line 69 of file CircularQueue.h.
Referenced by CircularQueue< T >::getFromMark(), CircularQueue< T >::moveMark(), and CircularQueue< T >::reset().
T* CircularQueue< T >::entry [protected] |
Definition at line 70 of file CircularQueue.h.
Referenced by CircularQueue< T >::CircularQueue(), CircularQueue< T >::get(), CircularQueue< T >::getFromMark(), CircularQueue< T >::put(), CircularQueue< T >::putArray(), CircularQueue< T >::reset(), and CircularQueue< T >::~CircularQueue().