forked from vieter-v/libvieter
feat(heap): code skeleton
parent
ad8c37c9ea
commit
050e99b413
2
Makefile
2
Makefile
|
@ -25,7 +25,7 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||||
# object file is also recompiled if only a header is changed.
|
# object file is also recompiled if only a header is changed.
|
||||||
# -MP: generate a dummy target for every header file (according to the docs it
|
# -MP: generate a dummy target for every header file (according to the docs it
|
||||||
# prevents some errors when removing header files)
|
# prevents some errors when removing header files)
|
||||||
CFLAGS ?= -MMD -MP -Wall -Werror -Wextra
|
CFLAGS ?= -MMD -MP -Wall -Wextra
|
||||||
CFLAGS += $(INC_FLAGS)
|
CFLAGS += $(INC_FLAGS)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef VIETER_HEAP
|
||||||
|
#define VIETER_HEAP
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef struct vieter_heap vieter_heap;
|
||||||
|
|
||||||
|
typedef enum vieter_heap_error {
|
||||||
|
vieter_heap_ok = 0,
|
||||||
|
vieter_heap_empty = 1
|
||||||
|
} vieter_heap_error;
|
||||||
|
|
||||||
|
vieter_heap *vieter_heap_init();
|
||||||
|
|
||||||
|
void vieter_heap_free(vieter_heap *heap);
|
||||||
|
|
||||||
|
uint64_t vieter_heap_size(vieter_heap *heap);
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_insert(vieter_heap *heap, uint64_t key, void *data);
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_pop(void **out, vieter_heap *heap);
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "vieter_heap.h"
|
||||||
|
|
||||||
|
struct vieter_heap {
|
||||||
|
uint64_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
vieter_heap *vieter_heap_init() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t vieter_heap_size(vieter_heap *heap) {
|
||||||
|
return heap->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vieter_heap_free(vieter_heap *heap) {}
|
||||||
|
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_insert(vieter_heap *heap, uint64_t key, void *data) {
|
||||||
|
return vieter_heap_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_pop(void **out, vieter_heap *heap) {
|
||||||
|
return vieter_heap_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap) {
|
||||||
|
return vieter_heap_ok;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "acutest.h"
|
||||||
|
#include "vieter_heap.h"
|
||||||
|
|
||||||
|
#define TEST_SIZE(heap, size) \
|
||||||
|
TEST_CHECK(vieter_heap_size(heap) == size); \
|
||||||
|
TEST_MSG("Size: %zu", vieter_heap_size(heap))
|
||||||
|
|
||||||
|
void test_init() {
|
||||||
|
vieter_heap *heap = vieter_heap_init();
|
||||||
|
TEST_CHECK(heap != NULL);
|
||||||
|
TEST_SIZE(heap, 0);
|
||||||
|
vieter_heap_free(heap);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_LIST = {
|
||||||
|
{"test_init", test_init},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
Loading…
Reference in New Issue