diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
commit | f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54 (patch) | |
tree | 53cec4864776e07950e3c72f2a990a1017d08045 /src/pqueue.h | |
download | libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.gz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.bz2 libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.xz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.zip |
libbu++ is finally laid out the way it should be, trunk, branches, and tags.
Diffstat (limited to 'src/pqueue.h')
-rw-r--r-- | src/pqueue.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/pqueue.h b/src/pqueue.h new file mode 100644 index 0000000..1b45f75 --- /dev/null +++ b/src/pqueue.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef PQUEUE_H | ||
2 | #define PQUEUE_H | ||
3 | |||
4 | #include "queue.h" | ||
5 | |||
6 | /** Priority queue. This is just like a queue, but something with a higher | ||
7 | * priority will always come off the queue before something with a lower | ||
8 | * priority, even if it's added after. Otherwise works just like a queue. | ||
9 | *@author Mike Buland | ||
10 | */ | ||
11 | class PQueue | ||
12 | { | ||
13 | public: | ||
14 | /** Create a queue with any number of different priorities. | ||
15 | *@param nNewNumQueues The number of queues, the default is 3 | ||
16 | */ | ||
17 | PQueue( int nNewNumQueues=3 ); | ||
18 | |||
19 | /** | ||
20 | * Cleanup all contained queues. | ||
21 | */ | ||
22 | ~PQueue(); | ||
23 | |||
24 | /** Add a new item to the queue at the specified priority. A lower | ||
25 | * number means a higher priority! | ||
26 | *@param pData A pointer to the data to add to the queue | ||
27 | *@param nQueueLevel The priority to set the new data to | ||
28 | */ | ||
29 | void enqueue( void *pData, int nQueueLevel ); | ||
30 | |||
31 | /** Pull the next item off the queue, high priority first. | ||
32 | *@returns A pointer to the data that was next in the priority queue | ||
33 | */ | ||
34 | void *dequeue(); | ||
35 | |||
36 | private: | ||
37 | /** | ||
38 | * The queues we use for real data storage. | ||
39 | */ | ||
40 | Queue *aQueue; | ||
41 | |||
42 | /** | ||
43 | * The number of priorities or queus that we need. | ||
44 | */ | ||
45 | int nNumQueues; | ||
46 | }; | ||
47 | |||
48 | #endif | ||