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 PID MMA8451Q
queue.h
00001 /**************************** queue.h ****************************************/ 00002 /* */ 00003 /* Authers: Greg Abdo. */ 00004 /* Date: February 23, 2013 */ 00005 /* Version: 1.0 */ 00006 /* */ 00007 /* The queue is used to stack StructureItem in order with a FILO arrangement.*/ 00008 /*****************************************************************************/ 00009 00010 #ifndef QUEUE_H 00011 #define QUEUE_H 00012 00013 #include "mbed.h" 00014 00015 using namespace std; 00016 00017 const int MAXQUEUELENGTH = 5; 00018 00019 class queue 00020 { 00021 public: 00022 queue(); // Queue constructor 00023 ~queue(); // Queue destructor 00024 00025 bool isEmpty(); // Check for an empty queue. 00026 void clear(); // Clears the entire queue. 00027 void add( short* ); // Push commandData into the queue. 00028 short* peek(); // Look at the last item in the queue. 00029 short* pop(); // Pop the top item off the queue. 00030 short queueLength(); // Return how many objects are in the queue. 00031 00032 private: 00033 int length; 00034 00035 struct queueNode // Node object for the queue. 00036 { 00037 queueNode( short* array ) 00038 { 00039 data = array; 00040 next = NULL; 00041 } 00042 00043 ~queueNode() 00044 {} 00045 00046 short* data; // Pointer to the StructureItem object. 00047 queueNode * next; // Next node in the queue. 00048 }; 00049 00050 queueNode * front; // Root of the queue. 00051 }; 00052 00053 #endif
Generated on Tue Jul 12 2022 19:58:00 by
