#ifndef SWIFT_DATA_HEAP_H
#define SWIFT_DATA_HEAP_H

#include <swift/stdlib.h>

#include <swift/data/api.h>
#include <swift/data/array.h>
#include <swift/data/types.h>

typedef enum swift_heap_type_t swift_heap_type_t;
typedef struct swift_heap_t swift_heap_t;

enum swift_heap_type_t {
	SWIFT_MAX_HEAP = -1,
	SWIFT_MIN_HEAP = 1,
};

struct swift_heap_t {
	swift_array_t array;
	swift_cmp_fn_t cmp;
	int heap_type;
};

SWIFT_DATA_API bool swift_init_heap_size(swift_heap_t *heap, swift_cmp_fn_t cmp,
	bool heap_type, size_t item_size, size_t size);
SWIFT_DATA_API bool swift_init_heap(swift_heap_t *heap, swift_cmp_fn_t cmp,
	bool heap_type, size_t item_size);
SWIFT_DATA_API void swift_term_heap(swift_heap_t *heap);
SWIFT_DATA_API swift_heap_t *swift_new_heap_size(swift_cmp_fn_t cmp,
	bool heap_type, size_t item_size, size_t size);
SWIFT_DATA_API swift_heap_t *swift_new_heap(swift_cmp_fn_t cmp, bool heap_type,
	size_t item_size);
SWIFT_DATA_API void swift_del_heap(swift_heap_t *heap);
SWIFT_DATA_API bool swift_heap_resize(swift_heap_t *heap, size_t size);
SWIFT_DATA_API bool swift_heap_expand(swift_heap_t *heap, size_t count);

SWIFT_DATA_API void *swift_heap_get(swift_heap_t *heap);
SWIFT_DATA_API size_t swift_heap_push(swift_heap_t *heap, void *entry);
SWIFT_DATA_API size_t swift_heap_pop(swift_heap_t *heap);

#endif /* SWIFT_DATA_HEAP_H */
