ISC DHCP  4.4.1
A reference DHCPv4 and DHCPv6 implementation
heap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2017 Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1997-2003 Internet Software Consortium.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /* $Id: heap.h,v 1.3 2007/05/19 19:16:25 dhankins Exp $ */
19 
20 #ifndef ISC_HEAP_H
21 #define ISC_HEAP_H 1
22 
25 /*%
26  * The comparision function returns ISC_TRUE if the first argument has
27  * higher priority than the second argument, and ISC_FALSE otherwise.
28  */
29 typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *);
30 
31 /*%
32  * The index function allows the client of the heap to receive a callback
33  * when an item's index number changes. This allows it to maintain
34  * sync with its external state, but still delete itself, since deletions
35  * from the heap require the index be provided.
36  */
37 typedef void (*isc_heapindex_t)(void *, unsigned int);
38 
39 /*%
40  * The heapaction function is used when iterating over the heap.
41  *
42  * NOTE: The heap structure CANNOT BE MODIFIED during the call to
43  * isc_heap_foreach().
44  */
45 typedef void (*isc_heapaction_t)(void *, void *);
46 
47 typedef struct isc_heap isc_heap_t;
48 
49 isc_result_t
51  isc_heapindex_t index, unsigned int size_increment,
52  isc_heap_t **heapp);
78 void
87 isc_result_t
88 isc_heap_insert(isc_heap_t *heap, void *elt);
96 void
97 isc_heap_delete(isc_heap_t *heap, unsigned int index);
107 void
108 isc_heap_increased(isc_heap_t *heap, unsigned int index);
119 void
120 isc_heap_decreased(isc_heap_t *heap, unsigned int index);
131 void *
132 isc_heap_element(isc_heap_t *heap, unsigned int index);
145 void
146 isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap);
163 #endif /* ISC_HEAP_H */
struct isc_heap isc_heap_t
Definition: heap.h:47
isc_result_t isc_heap_create(isc_heapcompare_t compare, isc_heapindex_t index, unsigned int size_increment, isc_heap_t **heapp)
Create a new heap. The heap is implemented using a space-efficient storage method....
void isc_heap_decreased(isc_heap_t *heap, unsigned int index)
Indicates to the heap that an element's priority has decreased. This function MUST be called whenever...
void(* isc_heapindex_t)(void *, unsigned int)
Definition: heap.h:37
void isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap)
Iterate over the heap, calling an action for each element. The order of iteration is not sorted.
void(* isc_heapaction_t)(void *, void *)
Definition: heap.h:45
void isc_heap_destroy(isc_heap_t **heapp)
Destroys a heap.
void isc_heap_increased(isc_heap_t *heap, unsigned int index)
Indicates to the heap that an element's priority has increased. This function MUST be called whenever...
void isc_heap_delete(isc_heap_t *heap, unsigned int index)
Deletes an element from a heap, by element index.
const char int
Definition: omapip.h:442
void * isc_heap_element(isc_heap_t *heap, unsigned int index)
Returns the element for a specific element index.
isc_boolean_t(* isc_heapcompare_t)(void *, void *)
Definition: heap.h:29
isc_result_t isc_heap_insert(isc_heap_t *heap, void *elt)
Inserts a new element into a heap.