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;
#define Mem_AllocTypeN(type, n)
void Sys_Error(const char *error,...)
#define Mem_ReAlloc(ptr, size)
void PQueuePush(priorityQueue_t *pq, const pos4_t item, priorityQueueRating_t r)
the priority queue struct the actual data is stored in priorityQueueElement_t
void PQueueFree(priorityQueue_t *pq)
free up memory for pqueue
int priorityQueueRating_t
#define PQueueIsEmpty(pq)
Header file for the priority queue implementation.
priorityQueueElement_t * elements
#define PQ_LEFT_CHILD_INDEX(i)
#define PQ_PARENT_INDEX(i)
void PQueuePop(priorityQueue_t *pq, pos4_t item)
remove the first node from the pqueue and provide a pointer to it
definitions common between client and server, but not game lib
priorityQueueRating_t rating
void PQueueInitialise(priorityQueue_t *pq, uint32_t maxElements)
initialise the priority queue with a maximum size of maxelements.