46 : m_array(array), m_arrayLength(N), m_size(0), m_head(-1), m_tail(-1) {
58 Queue (T *array,
const size_t length)
59 : m_array(array), m_arrayLength(length), m_size(0), m_head(-1), m_tail(-1) {
77 return 0 == this->
size();
86 return this->m_arrayLength == this->
size();
112 if (this->m_arrayLength == (
unsigned int) this->m_head)
116 this->m_array[this->m_head] = value;
120 this->m_tail = this->m_head;
123 if (this->
size() == this->m_arrayLength) {
126 if ((
unsigned int) this->m_tail == this->m_arrayLength)
150 T *retVal = &this->m_array[this->m_tail];
157 if ((
unsigned int) this->m_tail == this->m_arrayLength)
177 return this->m_array[this->m_tail];
192 const bool valid = &value == NULL;
198 const size_t m_arrayLength;
200 volatile size_t m_size;
A basic first-in, first-out queue implementation. The queue will overwrite itself when the maximum si...
T dequeue()
Return and remove the oldest value in the buffer.
Queue & enqueue(const T &value)
Insert an element to the buffer.
Generic definitions and functions for the Parallax Propeller.
Queue & insert(const T &value)
bool is_empty() const
Determine if any elements exist.
Queue(T(&array)[N])
Construct a queue using the given statically-allocated array.
Queue(T *array, const size_t length)
Construct a queue using the given dynamically allocated array (i.e., with new or malloc) ...
bool check(const T &value) const
Determine if a value is valid.
size_t size() const
Obtain the number of elements in the queue.
void clear()
Remove all data from the queue.
T peek() const
Return the oldest value in the buffer without removing it from the buffer.
bool is_full() const
Determine if inserting another element would overwrite data.