/*********************************************************************** * equeue.h * * Header file for a simple inplementation of an expandable queue * * Written by Paul Bonamy - 23 May 2010 ************************************************************************/ #ifndef EQUEUE_H #define EQUEUE_H /*********************************************************************** * really, really simple node class. * Could be expanded with accessor methods, additional data, etc ***********************************************************************/ class Node { public: int value; // value stored in the list Node * next; // next node in the list. set to 0 if last node Node * prev; // previous node in the list, 0 if first node Node() { next = prev = 0; } // default constructor. pretty trivial }; /*********************************************************************** * Simple expandable queue class. uses a linked list in the background * Implements basic enqueue, dequeue, and empty ***********************************************************************/ class EQueue { private: Node * head; // address of first node in the list Node * tail; // address of last node in the list public: EQueue(); // default constructor ~EQueue(); // destructor void enqueue(int v); // enqueue a value int dequeue(int &v); // dequeue a value void empty(); // delete all values in the queue }; #endif