summaryrefslogtreecommitdiff
path: root/src/pqueue.cpp
blob: 1f0b8b57f72cfaafc46ffa9fcb4bddb6af3dd6e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "pqueue.h"

PQueue::PQueue( int nNewNumQueues )
{
	nNumQueues = nNewNumQueues;
	aQueue = new Queue[nNumQueues];
}

PQueue::~PQueue()
{
	delete[] aQueue;
}

void PQueue::enqueue( void *pData, int nQueueLevel )
{
	if( nQueueLevel < 0 || nQueueLevel >= nNumQueues )
		return;

	aQueue[nQueueLevel].enqueue( pData );
}

void *PQueue::dequeue()
{
	for( int j = 0; j < nNumQueues; j++ )
	{
		if( aQueue[j].isEmpty() == false )
		{
			return aQueue[j].dequeue();
		}
	}

	return NULL;
}