27#define PQMH_TESTS(X) \
28 X("pqmh::empty", test_pqmh_empty), X("pqmh::ordering", test_pqmh_ordering), \
29 X("pqmh::peek", test_pqmh_peek), X("pqmh::grow", test_pqmh_grow)
35 return (intptr_t)a < (intptr_t)b;
40#define PQ_INT(v) ((void *)(intptr_t)(v))
66 int in[] = {5, 1, 4, 2, 8, 3, 7, 6, 0, 9};
67 enum { N = (int)(
sizeof(in) /
sizeof(in[0])) };
68 for (
int i = 0; i < N; i++) {
73 for (
int i = 0; i < N; i++) {
116 for (
int i = N - 1; i >= 0; i--) {
121 for (
int i = 0; i < N; i++) {
#define RELEASE_CONTEXT(x)
#define SHUTDOWN_ENGINE(mm, engine)
#define MAKE_ENGINE(mm, engine)
#define MAKE_CONTEXT(engine, x)
void pqmh_free(srn_context_t *ctx, pqmh_t *pq)
Release the backing array and reset the queue to empty.
void pqmh_push(srn_context_t *ctx, pqmh_t *pq, void *elem)
Insert elem, growing the backing array (doubling) if it is full.
pqmh_t pqmh_make(srn_context_t *ctx, const pqmh_control_t *ctl, size_t initial_cap)
Create an empty queue ordered by ctl, with room for initial_cap elements (a small default is used whe...
void * pqmh_peek(const pqmh_t *pq)
The highest priority element without removing it, or NULL when the queue is empty.
bool pqmh_pop(srn_context_t *ctx, pqmh_t *pq, void **out)
Remove the highest priority element into *out and return true, or return false (leaving *out untouche...
size_t pqmh_len(const pqmh_t *pq)
The number of elements currently in the queue.
A generic priority queue backed by a binary min-heap.
static void test_pqmh_empty()
static const pqmh_control_t pqmh_int_ctl
static void test_pqmh_peek()
static void test_pqmh_grow()
static bool pqmh_int_less(srn_context_t *ctx, const void *a, const void *b)
static void test_pqmh_ordering()