Go to the source code of this file.
Macros | |
#define | CL_PQUEUE_FOREACH(__type, __name, __queue, ...) |
Typedefs | |
typedef struct __PQueue | CL_PQueue |
typedef int(* | CL_PQueueCompareFn) (const void *, const void *) |
Functions | |
CL_PQueue * | CL_PQueueAllocWithCapacity (MEM_Allocator *const alloc, u32 capacity, u32 elem_sz, CL_PQueueCompareFn compare_fn) |
Initializes a priority queue with the allocated memory provided by the user. | |
CL_PQueue * | CL_PQueueAlloc (MEM_Allocator *const alloc, u32 elem_sz, CL_PQueueCompareFn compare_fn) |
Initializes a priority queue with a default capacity. | |
void | CL_PQueueFree (CL_PQueue *const pq) |
Frees the memory previously assigned to the priority queue. | |
CL_Error | CL_PQueueEnqueue (CL_PQueue *const pq, const void *const elem) |
Adds an element to the priority queue. | |
CL_Error | CL_PQueueDequeue (CL_PQueue *const pq, void *out_elem) |
Removes the element with the highest priority from the priority queue. | |
CL_Error | CL_PQueuePeek (const CL_PQueue *const pq, void *out_elem) |
Gets the element with the highest priority from the priority queue without removing it. | |
u32 | CL_PQueueSize (const CL_PQueue *const pq) |
Gets the number of elements in the priority queue. | |
bool | CL_PQueueIsEmpty (const CL_PQueue *const pq) |
Checks if the priority queue is empty. | |
#define CL_PQUEUE_FOREACH | ( | __type, | |
__name, | |||
__queue, | |||
... | |||
) |
Definition at line 15 of file cl_prioqueue.h.
Definition at line 11 of file cl_prioqueue.h.
typedef int(* CL_PQueueCompareFn) (const void *, const void *) |
Definition at line 29 of file cl_prioqueue.h.
CL_PQueue * CL_PQueueAlloc | ( | MEM_Allocator *const | alloc, |
u32 | elem_sz, | ||
CL_PQueueCompareFn | compare_fn | ||
) |
Initializes a priority queue with a default capacity.
alloc | The memory allocator to use. |
elem_sz | The size of each element. |
compare_fn | The comparison function to use for handling priorities. |
Definition at line 143 of file cl_prioqueue.c.
CL_PQueue * CL_PQueueAllocWithCapacity | ( | MEM_Allocator *const | alloc, |
u32 | capacity, | ||
u32 | elem_sz, | ||
CL_PQueueCompareFn | compare_fn | ||
) |
Initializes a priority queue with the allocated memory provided by the user.
allocator | The memory allocator to use. |
capacity | The initial capacity of the priority queue. |
elem_sz | The size of each element. |
compare_fn | The comparison function to use for handling priorities. |
Definition at line 115 of file cl_prioqueue.c.
Removes the element with the highest priority from the priority queue.
pq | The priority queue to remove the element from. |
out_elem | [OUTPUT] The element with the highest priority. |
Definition at line 179 of file cl_prioqueue.c.
Adds an element to the priority queue.
pq | The priority queue to add the element to. |
elem | The element to add. |
Definition at line 157 of file cl_prioqueue.c.
void CL_PQueueFree | ( | CL_PQueue *const | pq | ) |
Frees the memory previously assigned to the priority queue.
pq | The priority queue to release the memory of. |
Definition at line 148 of file cl_prioqueue.c.
bool CL_PQueueIsEmpty | ( | const CL_PQueue *const | pq | ) |
Checks if the priority queue is empty.
pq | The priority queue to check. |
Definition at line 216 of file cl_prioqueue.c.
Gets the element with the highest priority from the priority queue without removing it.
pq | The priority queue to get the element from. |
out_elem | [OUTPUT] The element with the highest priority. |
Definition at line 198 of file cl_prioqueue.c.
Gets the number of elements in the priority queue.
pq | The priority queue to get the number of elements from. |
Definition at line 211 of file cl_prioqueue.c.