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 void
37 ccl_heap_delete (ccl_heap *h);
38 
39 extern void
40 ccl_heap_clear (ccl_heap *h, ccl_delete_proc *del);
41 
42 extern void
43 ccl_heap_clear_and_delete (ccl_heap *help, ccl_delete_proc *del);
44 
45 # define ccl_heap_is_empty(h) (ccl_heap_get_size (h) == 0)
46 
47 extern int
48 ccl_heap_get_size (const ccl_heap *h);
49 
50 extern void *
51 ccl_heap_get_first (const ccl_heap *h);
52 
53 extern void *
54 ccl_heap_take_first (ccl_heap *h);
55 
56 extern void
57 ccl_heap_add (ccl_heap *h, void *obj);
58 
59 extern int
60 ccl_heap_has (const ccl_heap *h, void *obj);
61 
62 extern void
63 ccl_heap_log (ccl_log_type log, ccl_heap *h,
64  void (*logproc) (ccl_log_type log, void *obj, void *data),
65  void *data);
66 
67 END_C_DECLS
68 
69 #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.