TaPAS  0.2
ccl-heap.h
Go to the documentation of this file.
1 /*
2  * ccl-heap.h -- A generic binary heap
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
22 #ifndef __CCL_HEAP_H__
23 # define __CCL_HEAP_H__
24 
25 # include <ccl/ccl-common.h>
26 # include <ccl/ccl-log.h>
27 # include <ccl/ccl-protos.h>
28 
29 BEGIN_C_DECLS
30 
31 typedef struct ccl_heap_st ccl_heap;
32 
33 extern ccl_heap *
34 ccl_heap_create (int size, ccl_compare_func *cmp);
35 
36 extern ccl_heap *
37 ccl_heap_create_with_data (int size, ccl_compare_with_data_func *cmp,
38  void *data);
39 
40 extern void
41 ccl_heap_delete (ccl_heap *h);
42 
43 extern void
44 ccl_heap_clear (ccl_heap *h, ccl_delete_proc *del);
45 
46 extern void
47 ccl_heap_clear_and_delete (ccl_heap *help, ccl_delete_proc *del);
48 
49 # define ccl_heap_is_empty(h) (ccl_heap_get_size (h) == 0)
50 
51 extern int
52 ccl_heap_get_size (const ccl_heap *h);
53 
54 extern void *
55 ccl_heap_get_first (const ccl_heap *h);
56 
57 extern void *
58 ccl_heap_take_first (ccl_heap *h);
59 
60 extern void
61 ccl_heap_add (ccl_heap *h, void *obj);
62 
63 extern int
64 ccl_heap_has (const ccl_heap *h, void *obj);
65 
66 extern void
67 ccl_heap_copy (ccl_heap *dst, const ccl_heap *src);
68 
69 extern void
70 ccl_heap_log (ccl_log_type log, ccl_heap *h,
71  void (*logproc) (ccl_log_type log, void *obj, void *data),
72  void *data);
73 
74 END_C_DECLS
75 
76 #endif /* ! __CCL_HEAP_H__ */
Frequently used prototypes of generic functions.
int ccl_compare_func(const void *ptr1, const void *ptr2)
Prototype of functions used to order two objects pointed respectively by ptr1 and ptr2...
Definition: ccl-protos.h:73
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
Definition: ccl-protos.h:44
Some useful and common macros.
enum ccl_log_type_enum ccl_log_type
Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed ...
Definition: ccl-log.h:50
Message displayer.