Go to the source code of this file.
Classes | |
| struct | __PQueue |
Macros | |
| #define | RESZ_FACTOR 2 |
| #define | BASE_CAPACITY 10 |
| #define | PARENT(i) ((i - 1) / 2) |
| #define | LEFT(i) (2 * i + 1) |
| #define | RIGHT(i) (2 * i + 2) |
Functions | |
| _PRIVATE void | pSwap (void *const a, void *const b, u32 size) |
| _PRIVATE void | bubble_up_leaf (CL_PQueue *const pq) |
| _PRIVATE void | bubble_down_root (CL_PQueue *const pq) |
| _PRIVATE void * | realloc_data (CL_PQueue *const pq, u32 new_capacity) |
| 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 BASE_CAPACITY 10 |
Definition at line 18 of file cl_prioqueue.c.
| #define LEFT | ( | i | ) | (2 * i + 1) |
Definition at line 26 of file cl_prioqueue.c.
| #define PARENT | ( | i | ) | ((i - 1) / 2) |
Definition at line 25 of file cl_prioqueue.c.
| #define RESZ_FACTOR 2 |
Definition at line 17 of file cl_prioqueue.c.
| #define RIGHT | ( | i | ) | (2 * i + 2) |
Definition at line 27 of file cl_prioqueue.c.
Definition at line 61 of file cl_prioqueue.c.
Definition at line 40 of file cl_prioqueue.c.
| 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.
Definition at line 29 of file cl_prioqueue.c.
Definition at line 102 of file cl_prioqueue.c.