/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: queue.h 211 2007-09-03 17:07:26Z rick $ * Copyright : FreeBSD Licence */ #include "list.h" /* * Class Queue general declarations */ class Queue { public: Queue (); virtual ~Queue (void); bool IsEmpty (void); /* pure virtual decleration see: http://tinyurl.com/2apd5n * http://en.wikipedia.org/wiki/Virtual_function# \ * Abstract_classes_and_pure_virtual_functions */ virtual void Insert (const int item) = 0; virtual int Get (void) = 0; protected: int Pop (); int Shift (); void Push (const int item); void SortBySize (const int item); void Unshift (const int item); List * lijst; }; /* * Class Fifo declarations */ class Fifo: public Queue { public: // Push item to the end to the list void Insert (const int item) { Queue::Push (item); }; //Remove the Item longest in the queue, return 0 when list empty int Get (void) { return( Queue::Shift() ) ; }; }; /* * Class Lifo declarations */ class Lifo: public Queue { public: // Push item to the end to the list void Insert (const int item) { Queue::Push (item); }; //Remove the Item which came the last in the queue, return 0 //when list is empty int Get (void) { return( Queue::Pop() ); }; }; /* * Class MinQ declarations */ class MinQ: public Queue { public: // Push item to the sorted list void Insert (const int item) { Queue::SortBySize (item); }; //Remove the smallest item in the queue, return 0 //when list is empty int Get (void) { return( Queue::Shift() ); }; }; /* * Class MaxQ declarations */ class MaxQ: public Queue { public: // Push item to the sorted list void Insert (const int item) { Queue::SortBySize (item); }; //Remove the biggest item in the queue, return 0 //when list is empty int Get (void) { return( Queue::Pop() ); }; };