Queue handling library (designed on Arduino)
This library was designed for Arduino, yet may be compiled without change with gcc for other purposes/targets
- Declare a Queue instance
(uint16_t size_rec, uint16_t nb_recs=20, QueueType type=FIFO, overwrite=false)
(calledq
below):size_rec
- size of a record in the queuenb_recs
- number of records in the queuetype
- Queue implementation type: FIFO, LIFOoverwrite
- Overwrite previous records when queue is full if set to true
- Push stuff to the queue using
q.push(void * rec)
- returns
true
if successfully pushed into queue - returns
false
is queue is full
- returns
- Pop stuff from the queue using
q.pop(void * rec)
orq.pull(void * rec)
- returns
true
if successfully popped from queue - returns
false
if queue is empty
- returns
- Peek stuff from the queue using
q.peek(void * rec)
- returns
true
if successfully peeked from queue - returns
false
if queue is empty
- returns
- Drop stuff from the queue using
q.Drop(void)
- returns
true
if successfully dropped from queue - returns
false
if queue is empty
- returns
- Other methods:
q.IsInitialized()
:true
if initialized properly,false
otherwiseq.isEmpty()
:true
if full,false
otherwiseq.isFull()
:true
if empty,false
otherwiseq.sizeOf()
: queue size in bytes (returns 0 in case queue allocation failed)q.getCount()
orq.nbRecs()
: number of records stored in the queueq.getRemainingCount()
: number of records left in the queueq.clean()
orq.flush()
: remove all items in the queue
- SimpleQueue.ino: Simple queue example (both LIFO FIFO implementations can be tested)
- PointersQueue.ino: Queue of string pointers for string processing
- RolloverTest.ino: Simple test to test queue rollover (for lib testing purposes mainly)
- LibTst.ino: flexible test (for lib testing purposes mainly)
Doxygen doc can be generated using "Doxyfile".
See release notes
cQueue - C implementation of this library