33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
#ifndef BREEZE_HEAP_H
|
|
#define BREEZE_HEAP_H
|
|
|
|
#include "../defines.h"
|
|
|
|
void *_bzHeapCreate(i32 startCapacity, i32 stride, i32 weightOffset);
|
|
void _bzHeapDestroy(void *heap);
|
|
void _bzHeapClear(void *heap);
|
|
|
|
i32 _bzHeapSize(void *heap);
|
|
bool _bzHeapIsEmpty(void *heap);
|
|
i32 _bzHeapPop(void *heap);
|
|
void _bzHeapPush(void *heap);
|
|
i32 _bzHeapPushIdx(void *heap);
|
|
void _bzHeapUpdate(void *heap, i32 idx);
|
|
|
|
#define bzHeapCreate(T, n) (T *) ((T *)_bzHeapCreate((n), sizeof(T), offsetof(T, weight)))
|
|
#define bzHeapDestroy(heap) _bzHeapDestroy((void *) (heap))
|
|
#define bzHeapClear(heap) _bzHeapClear((void *) (heap))
|
|
|
|
#define bzHeapSize(heap) _bzHeapSize((void *) (heap))
|
|
#define bzHeapIsEmpty(heap) _bzHeapIsEmpty((void *) (heap))
|
|
#define bzHeapPop(heap) ((heap)[_bzHeapPop((void *) (heap))])
|
|
#define bzHeapPush(heap, ...) do { \
|
|
void *h = (void *) (heap); \
|
|
(heap)[_bzHeapPushIdx(h)] = (__VA_ARGS__); \
|
|
_bzHeapPush(h); \
|
|
} while(0)
|
|
#define bzHeapUpdate(heap, idx) _bzHeapUpdate((void *) heap, idx)
|
|
|
|
|
|
#endif //BREEZE_HEAP_H
|