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