Files
PixelDefense/engine/tests/heap_test.c

36 lines
710 B
C

#include <breeze.h>
#include <stdio.h>
int main() {
bzLoggerInit();
typedef struct Node {
i32 weight;
} Node;
Node *heap = bzHeapCreate(Node, 20);
bzHeapPush(heap, (Node) {3});
bzHeapPush(heap, (Node) {2});
bzHeapPush(heap, (Node) {1});
bzHeapPush(heap, (Node) {15});
bzHeapPush(heap, (Node) {2});
bzHeapPush(heap, (Node) {8});
bzHeapPush(heap, (Node) {10});
bzHeapPop(heap);
for (int i = 0; i < bzHeapSize(heap); i++) {
printf("%d ", heap[i].weight);
}
printf("\n\n");
while (!bzHeapIsEmpty(heap)) {
Node node = bzHeapPop(heap);
printf("%d\n", node.weight);
}
bzHeapDestroy(heap);
return 0;
}