Implementation of a priority queue by using a binary heap. More...
#include "common.h"
#include "pqueue.h"
Go to the source code of this file.
Defines | |
#define | PQ_PARENT_INDEX(i) ((i)>>1) |
#define | PQ_FIRST_ENTRY (1) |
#define | PQ_LEFT_CHILD_INDEX(i) ((i)<<1) |
#define | PQ_RIGHT_CHILD_INDEX(i) (((i)<<1)+1) |
#define | PGetRating(elem) ((elem).rating) |
Functions | |
void | PQueueInitialise (priorityQueue_t *pq, uint32_t maxElements) |
initialise the priority queue with a maximum size of maxelements. | |
void | PQueuePush (priorityQueue_t *pq, pos4_t item, priorityQueueRating_t r) |
void | PQueueFree (priorityQueue_t *pq) |
free up memory for pqueue | |
void | PQueuePop (priorityQueue_t *pq, pos4_t item) |
remove the first node from the pqueue and provide a pointer to it |
Implementation of a priority queue by using a binary heap.
Definition in file pqueue.c.
#define PQ_FIRST_ENTRY (1) |
Definition at line 27 of file pqueue.c.
Referenced by PQueuePop(), and PQueuePush().
Definition at line 30 of file pqueue.c.
Referenced by PQueuePop().
Definition at line 26 of file pqueue.c.
Referenced by PQueuePush().
void PQueueFree | ( | priorityQueue_t * | pq | ) |
free up memory for pqueue
Definition at line 87 of file pqueue.c.
References priorityQueue_s::elements.
Referenced by Grid_MoveCalc().
void PQueueInitialise | ( | priorityQueue_t * | pq, | |
uint32_t | maxElements | |||
) |
initialise the priority queue with a maximum size of maxelements.
Definition at line 38 of file pqueue.c.
References priorityQueue_s::currentSize, priorityQueue_s::elements, priorityQueue_s::maxSize, and Sys_Error().
Referenced by Grid_MoveCalc().
void PQueuePop | ( | priorityQueue_t * | pq, | |
pos4_t | item | |||
) |
remove the first node from the pqueue and provide a pointer to it
Definition at line 95 of file pqueue.c.
References priorityQueue_s::currentSize, priorityQueue_s::elements, i, priorityQueueElement_s::item, PQ_FIRST_ENTRY, PQ_LEFT_CHILD_INDEX, PQueueIsEmpty, and priorityQueueElement_s::rating.
Referenced by Grid_MoveCalc().
void PQueuePush | ( | priorityQueue_t * | pq, | |
pos4_t | item, | |||
priorityQueueRating_t | r | |||
) |
Definition at line 49 of file pqueue.c.
References priorityQueue_s::currentSize, priorityQueue_s::elements, i, priorityQueueElement_s::item, priorityQueue_s::maxSize, PQ_FIRST_ENTRY, PQ_PARENT_INDEX, and priorityQueueElement_s::rating.
Referenced by Grid_MoveCalc(), and Grid_SetMoveData().