diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
| commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
| tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/old/pqueue.h | |
| parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
| download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip | |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/old/pqueue.h')
| -rw-r--r-- | src/old/pqueue.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/old/pqueue.h b/src/old/pqueue.h new file mode 100644 index 0000000..8307d56 --- /dev/null +++ b/src/old/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 | virtual ~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 | ||
