1#ifndef __CL_PRIOQUEUE_H
2#define __CL_PRIOQUEUE_H
15#define CL_PQUEUE_FOREACH(__type, __name, __queue, ...) \
16 for (u32 __i = 0; __i < CL_PQueueSize(__queue); __i++) \
18 __type *__pq_arr = (__type *)CL_PQueueAsArray(__queue); \
19 __type __name = __pq_arr[__i]; \
88void *CL_PQueueAsArray(const CL_PQueue *const pq);
int(* CL_PQueueCompareFn)(const void *, const void *)
bool CL_PQueueIsEmpty(const CL_PQueue *const pq)
Checks if the priority queue is empty.
void CL_PQueueFree(CL_PQueue *const pq)
Frees the memory previously assigned to 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.
CL_Error CL_PQueueDequeue(CL_PQueue *const pq, void *out_elem)
Removes the element with the highest priority from the priority queue.
u32 CL_PQueueSize(const CL_PQueue *const pq)
Gets the number of elements in the priority queue.
CL_PQueue * CL_PQueueAlloc(MEM_Allocator *const alloc, u32 elem_sz, CL_PQueueCompareFn compare_fn)
Initializes a priority queue with a default 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_Error CL_PQueueEnqueue(CL_PQueue *const pq, const void *const elem)
Adds an element to the priority queue.
CL_Error
Specify this in the size parameter of the collections initialization to tell the library that the num...
CL_PQueueCompareFn compare_fn
The comparison function.