Header File for Queue ADT - Array Based Implementation
// ******************************************************** // Header file Queuearr.h for the ADT queue. // Array-based implementation. // ******************************************************** #ifndef QUEUEARR_H #define QUEUEARR_H const int MAX_QUEUE = 30; typedef type-of-queue-item queueItemType; class Queue { public: // constructors and destructor: Queue(); // default constructor // copy constructor and destructor are // supplied by the compiler // queue operations: // Determines whether a Queue is empty. // Precondition: None. // Postcondition: Returns true if the Queue is empty; otherwise returns false. int isEmpty(); // Inserts an item at the back of a Queue. // Precondition: NewItem is the item to be inserted. // Postcondition: If insertion was successful, NewItem is at the back of // the Queue and insert returns true; otherwise insert returns false. int insert(queueItemType NewItem); // Deletes the front of a Queue. // Precondition: None. // Postcondition: If the Queue was not empty, the item that was added to // the Queue earliest is deleted and del returns true. However, if the // Queue was empty, deletion is impossible and del returns false. int del(); // Retrieves and deletes the front of a Queue. // Precondition: None. // Postcondition: If the Queue was not empty, QueueFront contains the item // that was added to the Queue earliest, the item is deleted, and del returns // true. However, if the Queue was empty, deletion is impossible and del // returns false. int del(queueItemType& QueueFront); // Retrieves the item at the front of a Queue. // Precondition: None. // Postcondition: If the Queue was not empty, QueueFront contains the item // that was added to the Queue earliest and getFront returns true. However, // if the Queue was empty, the operation fails, QueueFront is unchanged, and // getFront returns false. The Queue is unchanged. int getFront(queueItemType& QueueFront); private: queueItemType Items[MAX_QUEUE]; int Front; int Back; int Count; }; // end class // End of header file. #endif
Email Me | Office Hours | My Home Page | Department Home | MCC Home Page