source: liacs/da/opdr1/queue.h@ 238

Last change on this file since 238 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 2.1 KB
RevLine 
[2]1/* Author : Rick van der Zwet
2 * S-number : 0433373
3 * Version : $Id: queue.h 211 2007-09-03 17:07:26Z rick $
4 * Copyright : FreeBSD Licence
5 */
6
7#include "list.h"
8
9/*
10 * Class Queue general declarations
11 */
12class Queue {
13 public:
14 Queue ();
15 virtual ~Queue (void);
16 bool IsEmpty (void);
17 /* pure virtual decleration see: http://tinyurl.com/2apd5n
18 * http://en.wikipedia.org/wiki/Virtual_function# \
19 * Abstract_classes_and_pure_virtual_functions
20 */
21 virtual void Insert (const int item) = 0;
22 virtual int Get (void) = 0;
23
24 protected:
25 int Pop ();
26 int Shift ();
27 void Push (const int item);
28 void SortBySize (const int item);
29 void Unshift (const int item);
30 List * lijst;
31};
32
33
34 /*
35 * Class Fifo declarations
36 */
37 class Fifo: public Queue {
38 public:
39 // Push item to the end to the list
40 void Insert (const int item) { Queue::Push (item); };
41 //Remove the Item longest in the queue, return 0 when list empty
42 int Get (void) { return( Queue::Shift() ) ; };
43 };
44
45
46
47 /*
48 * Class Lifo declarations
49 */
50 class Lifo: public Queue {
51 public:
52 // Push item to the end to the list
53 void Insert (const int item) { Queue::Push (item); };
54 //Remove the Item which came the last in the queue, return 0
55 //when list is empty
56 int Get (void) { return( Queue::Pop() ); };
57 };
58
59
60
61/*
62 * Class MinQ declarations
63 */
64class MinQ: public Queue {
65 public:
66 // Push item to the sorted list
67 void Insert (const int item) { Queue::SortBySize (item); };
68 //Remove the smallest item in the queue, return 0
69 //when list is empty
70 int Get (void) { return( Queue::Shift() ); };
71};
72
73
74
75/*
76 * Class MaxQ declarations
77 */
78class MaxQ: public Queue {
79 public:
80 // Push item to the sorted list
81 void Insert (const int item) { Queue::SortBySize (item); };
82 //Remove the biggest item in the queue, return 0
83 //when list is empty
84 int Get (void) { return( Queue::Pop() ); };
85};
Note: See TracBrowser for help on using the repository browser.