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