1 /* heap.h - Abstract heap type
2 * Copyright 2000-2001 srvx Development Team
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. Important limitations are
8 * listed in the COPYING file that accompanies this software.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, email srvx-maintainers@srvx.net.
22 typedef int (*comparator_f)(const void *a, const void *b);
24 /* a heap is implemented using a dynamically sized array */
25 typedef struct heap *heap_t;
27 /* operations on a heap */
28 heap_t heap_new(comparator_f comp);
29 void heap_insert(heap_t heap, void *key, void *data);
30 void heap_peek(heap_t heap, void **key, void **data);
31 void heap_pop(heap_t heap);
32 void heap_delete(heap_t heap);
33 unsigned int heap_size(heap_t heap);
34 int heap_remove_pred(heap_t heap, int (*pred)(void *key, void *data, void *extra), void *extra);
36 /* useful comparators */
38 /* int strcmp(const char *s1, const char *s2); from <string.h> can be used */
39 int int_comparator(const void*, const void*);
40 int timeval_comparator(const void*, const void*);
42 #endif /* ndef HEAP_H */