includes/heap.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1997-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: heap.h,v 1.3 2007/05/19 19:16:25 dhankins Exp $ */
00019 
00020 #ifndef ISC_HEAP_H
00021 #define ISC_HEAP_H 1
00022 
00025 /*%
00026  * The comparision function returns ISC_TRUE if the first argument has
00027  * higher priority than the second argument, and ISC_FALSE otherwise.
00028  */
00029 typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *);
00030 
00031 /*%
00032  * The index function allows the client of the heap to receive a callback
00033  * when an item's index number changes.  This allows it to maintain
00034  * sync with its external state, but still delete itself, since deletions
00035  * from the heap require the index be provided.
00036  */
00037 typedef void (*isc_heapindex_t)(void *, unsigned int);
00038 
00039 /*%
00040  * The heapaction function is used when iterating over the heap.
00041  *
00042  * NOTE:  The heap structure CANNOT BE MODIFIED during the call to
00043  * isc_heap_foreach().
00044  */
00045 typedef void (*isc_heapaction_t)(void *, void *);
00046 
00047 typedef struct isc_heap isc_heap_t;
00048 
00049 isc_result_t
00050 isc_heap_create(isc_heapcompare_t compare,
00051                 isc_heapindex_t index, unsigned int size_increment,
00052                 isc_heap_t **heapp);
00078 void
00079 isc_heap_destroy(isc_heap_t **heapp);
00087 isc_result_t
00088 isc_heap_insert(isc_heap_t *heap, void *elt);
00096 void
00097 isc_heap_delete(isc_heap_t *heap, unsigned int index);
00107 void
00108 isc_heap_increased(isc_heap_t *heap, unsigned int index);
00119 void
00120 isc_heap_decreased(isc_heap_t *heap, unsigned int index);
00131 void *
00132 isc_heap_element(isc_heap_t *heap, unsigned int index);
00145 void
00146 isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap);
00163 #endif /* ISC_HEAP_H */

Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1