//--------------------------------------------------------- // Lab09 // // Test the implementation of a queue class. // // D. Searls // REPLACE THIS LINE WITH YOUR NAME!! // Asbury University //--------------------------------------------------------- #include using namespace std; //********************************************************* // A queue object models a queue data structure. //********************************************************* template class queue { private: struct node { itemType info; node* next; }; node* head; node* tail; unsigned int n; public: //----------------------------------------------------- // Default Constructor // // Constructs an empty queue. //----------------------------------------------------- queue() { } //----------------------------------------------------- // Destructor // // Remove all of the items from the queue. //----------------------------------------------------- ~queue() { } //----------------------------------------------------- // push // // Push the specified item onto the end of the queue. // // In Parameter: item //----------------------------------------------------- void push(const itemType& item) { } //----------------------------------------------------- // pop // // Remove and discard the item at the front of the queue. // // Precondition: empty() is false. //----------------------------------------------------- void pop() { } //----------------------------------------------------- // empty // // Return true if the queue is empty and false // otherwise. //----------------------------------------------------- bool empty() { } //----------------------------------------------------- // front // // Return the item at the front of the queue. // // Precondition: empty() is false. //----------------------------------------------------- itemType front() { } //----------------------------------------------------- // size // // Return the number of items in this queue. //----------------------------------------------------- unsigned int size() { } }; void traverse(queue& q) { int data; cout << "Queue (size " << q.size() << ") is "; if (!q.empty()) { cout << "not "; } cout << "empty: "; for (unsigned int i = 0; i < q.size(); i++) { data = q.front(); q.pop(); cout << data << " "; q.push(data); } cout << endl; } //********************************************************* // M A I N D R I V E R //********************************************************* int main() { queue myQueue; traverse(myQueue); for (int i = 0; i < 9; i++) { myQueue.push(i); traverse(myQueue); } while (!myQueue.empty()) { myQueue.pop(); traverse(myQueue); } return 0; }