Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ESC SR04 TSI
Diff: com/queue/queue.h
- Revision:
- 32:d2b973c8d196
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/queue/queue.h Sun Jun 09 02:41:27 2013 +0000 @@ -0,0 +1,51 @@ +/**************************** queue.h ****************************************/ +/* */ +/* Authers: Greg Abdo. */ +/* Date: February 23, 2013 */ +/* Version: 1.0 */ +/* */ +/* The queue is used to stack StructureItem in order with a FILO arrangement.*/ +/*****************************************************************************/ + +#ifndef QUEUE_H +#define QUEUE_H + +#include "mbed.h" + +using namespace std; + +class queue +{ +public: + queue(); // Queue constructor + ~queue(); // Queue destructor + + bool isEmpty(); // Check for an empty queue. + void clear(); // Clears the entire queue. + void add( char* ); // Push commandData into the queue. + char* peek(); // Look at the last item in the queue. + char* pop(); // Pop the top item off the queue. + int queueLength(); // Return how many objects are in the queue. + +private: + int length; + + struct queueNode // Node object for the queue. + { + queueNode( char* array ) + { + data = array; + next = NULL; + } + + ~queueNode() + {} + + char* data; // Pointer to the StructureItem object. + queueNode * next; // Next node in the queue. + }; + + queueNode * front; // Root of the queue. +}; + +#endif