#ifndef __T_QUEUE_HPP__ #define __T_QUEUE_HPP__ const int SIZE = 1000; template class T_Queue { private: T q[SIZE]; int front, rear; // front points to the first element in the queue // rear points to the next element position in the queue to be inserted bool empty; public: T_Queue() { front = rear = 0; empty = true; } void enqueue(T elem); T dequeue(); bool isEmpty() { return empty; } bool isFull() { return ((!empty) && (front == rear)); } }; template void enqueue(T elem) { q[rear] = elem; empty = false; rear = (rear + 1) % SIZE; } template T dequeue() { if (isEmpty() == true) std:cout << "error\n"; T rlt = q[front]; front = (front + 1) % SIZE; if (front == rear) empty = true; return rlt; } #endif