muwerk ustd Library
A low-resource, minimal implementation of Arrays, Maps and Queues for low-resource avrs.
|
Lightweight c++11 ring buffer queue implementation. More...
#include <ustd_queue.h>
Public Member Functions | |
queue (unsigned int maxQueueSize) | |
~queue () | |
queueIterator< T > | begin () |
queueIterator< T > | end () |
queueIterator< const T > | begin () const |
queueIterator< const T > | end () const |
bool | push (T ent) |
T | pop () |
void | setInvalidValue (T &entryInvalidValue) |
bool | isEmpty () |
unsigned int | length () |
unsigned int | peak () |
Lightweight c++11 ring buffer queue implementation.
ustd_queue.h is a minimal, yet highly portable ring buffer queue implementation that runs well on architectures with very limited resources such as attiny 8kb avr.
Make sure to provide the required platform define before including ustd headers.
queue<int> que = queue<int>(16);
que.push(12); que.push(13);
Iterate through queue content (does not modify content) for (auto i : que) { printf("%d\n", i); }
New pop() the values: int w0,w1; w0=que.pop(); w1=que.pop(); Queue is now empty.
printf("%d %d, len=%d\n",w0,w1,que.length());
|
inline |
Constructs a queue object
maxQueueSize | The maximum number of entries, the queue can hold. |
|
inline |
Deallocate the queue structure.
|
inline |
Iterator support: begin()
|
inline |
Iterator support: begin()
|
inline |
Iterator support: end()
|
inline |
Iterator support: end()
|
inline |
Check, if queue is empty.
|
inline |
Check number of queue entries.
|
inline |
Check the maxiumum number of entries that have been in the queue.
|
inline |
Pop the oldest entry from the queue.
|
inline |
Push a new entry into the queue.
ent | T element |
|
inline |
Set the value that's given back, if read from an empty queue is requested. By default, an entry all set to zero is given back. Using this function, the value of an invalid read can be configured.
entryInvalidValue | The value that is given back in case an invalid operation (e.g. read out of bounds) is tried. |