24#define PQ_PARENT_INDEX(i) ((i)>>1)
25#define PQ_FIRST_ENTRY (1)
28#define PQ_LEFT_CHILD_INDEX(i) ((i)<<1)
29#define PQ_RIGHT_CHILD_INDEX(i) (((i)<<1)+1)
30#define PGetRating(elem) ((elem).rating)
44 Sys_Error(
"PQueueInitialise: Memory alloc failed!");
51 if (currentSize == pq->
maxSize) {
52 const int new_size = pq->
maxSize * 2;
58 uint32_t
i = (++currentSize);
72 for (
int j = 0; j < 4; j++)
104 for (
int j = 0; j < 4; j++)
105 item[j] = pMaxElement.
item[j];
112 if ((child != currentSize) && (elements[child + 1].
rating < elements[child].
rating))
116 elements[
i] = elements[child];
121 elements[
i] = pLastElement;
definitions common between client and server, but not game lib
void Sys_Error(const char *error,...)
#define Mem_AllocTypeN(type, n)
#define Mem_ReAlloc(ptr, size)
#define PQ_LEFT_CHILD_INDEX(i)
void PQueueFree(priorityQueue_t *pq)
free up memory for pqueue
void PQueueInitialise(priorityQueue_t *pq, uint32_t maxElements)
initialise the priority queue with a maximum size of maxelements.
#define PQ_PARENT_INDEX(i)
void PQueuePush(priorityQueue_t *pq, const pos4_t item, priorityQueueRating_t r)
void PQueuePop(priorityQueue_t *pq, pos4_t item)
remove the first node from the pqueue and provide a pointer to it
Header file for the priority queue implementation.
#define PQueueIsEmpty(pq)
int priorityQueueRating_t
the priority queue struct the actual data is stored in priorityQueueElement_t
priorityQueueElement_t * elements
priorityQueueRating_t rating