Rev | Line | |
---|
[3059] | 1 | /* $Id: queue.h,v 1.1 2000-03-09 19:03:20 sandervl Exp $ */
|
---|
| 2 |
|
---|
| 3 | /*
|
---|
| 4 | * Very simply generic queue class
|
---|
| 5 | *
|
---|
| 6 | * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | *
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | class Queue;
|
---|
| 13 |
|
---|
| 14 | //******************************************************************************
|
---|
| 15 | //******************************************************************************
|
---|
| 16 | class QueueItem
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
[21916] | 19 | QueueItem(ULONG dwItemData)
|
---|
[3059] | 20 | {
|
---|
| 21 | this->dwItemData = dwItemData;
|
---|
| 22 | next = NULL;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | private:
|
---|
| 26 | ULONG dwItemData;
|
---|
| 27 | QueueItem *next;
|
---|
| 28 |
|
---|
| 29 | friend class Queue;
|
---|
| 30 | };
|
---|
| 31 | //******************************************************************************
|
---|
| 32 | //******************************************************************************
|
---|
| 33 | class Queue
|
---|
| 34 | {
|
---|
| 35 | public:
|
---|
| 36 | Queue();
|
---|
| 37 | ~Queue();
|
---|
| 38 |
|
---|
| 39 | void Push(ULONG dwItemData);
|
---|
| 40 | void Remove(ULONG dwItemData);
|
---|
| 41 | void Remove(QueueItem *item);
|
---|
| 42 | ULONG Pop();
|
---|
| 43 |
|
---|
| 44 | void operator=(Queue&) ;
|
---|
| 45 |
|
---|
| 46 | QueueItem *Head() { return head; };
|
---|
| 47 | QueueItem *Tail() { return tail; };
|
---|
| 48 | QueueItem *getNext(QueueItem *item) { return item->next; };
|
---|
| 49 | ULONG getItem(QueueItem *item) { return item->dwItemData; };
|
---|
| 50 |
|
---|
| 51 | BOOL hasElements() { return head != NULL; };
|
---|
| 52 |
|
---|
| 53 | private:
|
---|
| 54 | void PushRev(Queue& queue, QueueItem *item);
|
---|
| 55 |
|
---|
| 56 | QueueItem *head;
|
---|
| 57 | QueueItem *tail;
|
---|
| 58 | };
|
---|
| 59 | //******************************************************************************
|
---|
| 60 | //******************************************************************************
|
---|
| 61 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.