#include #include #include "queue.h" using namespace std; /* Default constructor*/ template queue::queue() { queueFront = NULL; queueRear = NULL; size = 0; } /* Destructor */ template queue::~queue() { } /* Display for testing */ template void queue::display() { node *current = queueFront; cout << "Front --> "; while(current != NULL) { cout<data<< " "; current = current -> next; } cout < bool queue::isEmptyQueue() { return (queueFront == NULL); } /* Clear queue */ template void queue::clear() { queueFront = NULL; } /* Add new item to the queue */ template void queue::enQueue(Kind item) { node *newNode; newNode = new node; newNode->data = item; newNode->next = NULL; if (queueFront == NULL) { queueFront = newNode; queueRear = newNode; } else { queueRear->next = newNode; queueRear = queueRear->next; } size++; } /* Return the top element of the queue */ template Kind queue::front() { assert(queueFront != NULL); return queueFront->data; } /* Remove the element of the queue */ template void queue::deQueue() { node *temp; if(!isEmptyQueue()) { temp = queueFront; queueFront = queueFront->next; delete temp; size--; } else { cout << "Queue is empty !" << endl; } }