-
Notifications
You must be signed in to change notification settings - Fork 0
/
heap.h
35 lines (28 loc) · 807 Bytes
/
heap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef HEAP_H
# define HEAP_H
# ifdef __cplusplus
extern "C" {
# endif
# include <stdint.h>
struct heap_node;
typedef struct heap_node heap_node_t;
typedef struct heap {
heap_node_t *min;
uint32_t size;
int32_t (*compare)(const void *key, const void *with);
void (*datum_delete)(void *);
} heap_t;
void heap_init(heap_t *h,
int32_t (*compare)(const void *key, const void *with),
void (*datum_delete)(void *));
void heap_delete(heap_t *h);
heap_node_t *heap_insert(heap_t *h, void *v);
void *heap_peek_min(heap_t *h);
void *heap_remove_min(heap_t *h);
int heap_combine(heap_t *h, heap_t *h1, heap_t *h2);
int heap_decrease_key(heap_t *h, heap_node_t *n, void *v);
int heap_decrease_key_no_replace(heap_t *h, heap_node_t *n);
# ifdef __cplusplus
}
# endif
#endif