xref: /titanic_44/usr/src/lib/libresolv2/include/isc/heap.h (revision 1e4c938b57d1656808e4112127ff1dce3eba5314)
1 /*
2  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (c) 1997,1999 by Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 typedef int (*heap_higher_priority_func)(void *, void *);
19 typedef void (*heap_index_func)(void *, int);
20 typedef void (*heap_for_each_func)(void *, void *);
21 
22 typedef struct heap_context {
23 	int array_size;
24 	int array_size_increment;
25 	int heap_size;
26 	void **heap;
27 	heap_higher_priority_func higher_priority;
28 	heap_index_func index;
29 } *heap_context;
30 
31 #define heap_new	__heap_new
32 #define heap_free	__heap_free
33 #define heap_insert	__heap_insert
34 #define heap_delete	__heap_delete
35 #define heap_increased	__heap_increased
36 #define heap_decreased	__heap_decreased
37 #define heap_element	__heap_element
38 #define heap_for_each	__heap_for_each
39 
40 heap_context	heap_new(heap_higher_priority_func, heap_index_func, int);
41 int		heap_free(heap_context);
42 int		heap_insert(heap_context, void *);
43 int		heap_delete(heap_context, int);
44 int		heap_increased(heap_context, int);
45 int		heap_decreased(heap_context, int);
46 void *		heap_element(heap_context, int);
47 int		heap_for_each(heap_context, heap_for_each_func, void *);
48 
49 /*! \file */
50