I've been search, without success, for a FIFO library/class. I've seen topics and code snippets, none of which were quite what I was looking for, or understandable :-/
Can anyone point me to a true and proven FIFO Queue?
// read the next-to-be-dequeued event from the queue;
// returns true if successful, false if the
// queue is empty (the parameteres are not touched
// in this case)
boolean EventQueue::peekEvent(int* ev_code, int* ev_param) {
if (numEvents == 0) {
return false;
}
eventQueueTail = (eventQueueTail + 1) % EVQUEUE_SIZE;
// store event code and event parameter
// into the user-supplied variables
*ev_code = eventQueue[eventQueueTail];
*ev_param = eventParam[eventQueueTail];
// don't update the number of events in queue
// since we're only reading the queue head
//numEvents--;
return true;
}