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
com/queue/queue.h@16:5f736b955d53, 2013-06-06 (annotated)
- Committer:
- gabdo
- Date:
- Thu Jun 06 00:18:29 2013 +0000
- Revision:
- 16:5f736b955d53
Motor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gabdo | 16:5f736b955d53 | 1 | /**************************** queue.h ****************************************/ |
gabdo | 16:5f736b955d53 | 2 | /* */ |
gabdo | 16:5f736b955d53 | 3 | /* Authers: Greg Abdo. */ |
gabdo | 16:5f736b955d53 | 4 | /* Date: February 23, 2013 */ |
gabdo | 16:5f736b955d53 | 5 | /* Version: 1.0 */ |
gabdo | 16:5f736b955d53 | 6 | /* */ |
gabdo | 16:5f736b955d53 | 7 | /* The queue is used to stack StructureItem in order with a FILO arrangement.*/ |
gabdo | 16:5f736b955d53 | 8 | /*****************************************************************************/ |
gabdo | 16:5f736b955d53 | 9 | |
gabdo | 16:5f736b955d53 | 10 | #ifndef QUEUE_H |
gabdo | 16:5f736b955d53 | 11 | #define QUEUE_H |
gabdo | 16:5f736b955d53 | 12 | |
gabdo | 16:5f736b955d53 | 13 | #include "mbed.h" |
gabdo | 16:5f736b955d53 | 14 | |
gabdo | 16:5f736b955d53 | 15 | using namespace std; |
gabdo | 16:5f736b955d53 | 16 | |
gabdo | 16:5f736b955d53 | 17 | class queue |
gabdo | 16:5f736b955d53 | 18 | { |
gabdo | 16:5f736b955d53 | 19 | public: |
gabdo | 16:5f736b955d53 | 20 | queue(); // Queue constructor |
gabdo | 16:5f736b955d53 | 21 | ~queue(); // Queue destructor |
gabdo | 16:5f736b955d53 | 22 | |
gabdo | 16:5f736b955d53 | 23 | bool isEmpty(); // Check for an empty queue. |
gabdo | 16:5f736b955d53 | 24 | void clear(); // Clears the entire queue. |
gabdo | 16:5f736b955d53 | 25 | void add( char* ); // Push commandData into the queue. |
gabdo | 16:5f736b955d53 | 26 | char* peek(); // Look at the last item in the queue. |
gabdo | 16:5f736b955d53 | 27 | char* pop(); // Pop the top item off the queue. |
gabdo | 16:5f736b955d53 | 28 | void printAll(); // Print the entire queue. |
gabdo | 16:5f736b955d53 | 29 | |
gabdo | 16:5f736b955d53 | 30 | private: |
gabdo | 16:5f736b955d53 | 31 | struct queueNode // Node object for the queue. |
gabdo | 16:5f736b955d53 | 32 | { |
gabdo | 16:5f736b955d53 | 33 | queueNode( char* array ) |
gabdo | 16:5f736b955d53 | 34 | { |
gabdo | 16:5f736b955d53 | 35 | data = array; |
gabdo | 16:5f736b955d53 | 36 | next = NULL; |
gabdo | 16:5f736b955d53 | 37 | } |
gabdo | 16:5f736b955d53 | 38 | |
gabdo | 16:5f736b955d53 | 39 | ~queueNode() |
gabdo | 16:5f736b955d53 | 40 | {} |
gabdo | 16:5f736b955d53 | 41 | |
gabdo | 16:5f736b955d53 | 42 | char* data; // Pointer to the StructureItem object. |
gabdo | 16:5f736b955d53 | 43 | queueNode * next; // Next node in the queue. |
gabdo | 16:5f736b955d53 | 44 | }; |
gabdo | 16:5f736b955d53 | 45 | |
gabdo | 16:5f736b955d53 | 46 | queueNode * front; // Root of the queue. |
gabdo | 16:5f736b955d53 | 47 | }; |
gabdo | 16:5f736b955d53 | 48 | |
gabdo | 16:5f736b955d53 | 49 | #endif |