RNAlib-2.6.3
 
Loading...
Searching...
No Matches
heap.h
Go to the documentation of this file.
1#ifndef VIENNA_RNA_PACKAGE_HEAP_H
2#define VIENNA_RNA_PACKAGE_HEAP_H
3
4#ifdef VRNA_WARN_DEPRECATED
5# if defined(DEPRECATED)
6# undef DEPRECATED
7# endif
8# if defined(__clang__)
9# define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
10# elif defined(__GNUC__)
11# define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
12# else
13# define DEPRECATED(func, msg) func
14# endif
15#else
16# define DEPRECATED(func, msg) func
17#endif
18
40typedef struct vrna_heap_s *vrna_heap_t;
41
42
59typedef int (*vrna_heap_cmp_f)(const void *a,
60 const void *b,
61 void *data);
62
63DEPRECATED(typedef int (vrna_callback_heap_cmp)(const void *a,
64 const void *b,
65 void *data),
66 "Use vrna_heap_cmp_f instead!");
67
68
76typedef size_t (*vrna_heap_get_pos_f)(const void *a,
77 void *data);
78
79DEPRECATED(typedef size_t (vrna_callback_heap_get_pos)(const void *a,
80 void *data),
81 "Use vrna_heap_get_pos_f instead!");
82
83
91typedef void (*vrna_heap_set_pos_f)(const void *a,
92 size_t pos,
93 void *data);
94
95DEPRECATED(typedef void (vrna_callback_heap_set_pos)(const void *a,
96 size_t pos,
97 void *data),
98 "USe vrna_heap_set_pos_f instead!");
99
100
136 vrna_heap_cmp_f cmp,
137 vrna_heap_get_pos_f get_entry_pos,
138 vrna_heap_set_pos_f set_entry_pos,
139 void *data);
140
141
149void
151
152
159size_t
160vrna_heap_size(struct vrna_heap_s *h);
161
162
172void
174 void *v);
175
176
188void *
190
191
201const void *
203
204
218void *
220 const void *v);
221
222
239void *
241 void *v);
242
243
248#endif
vrna_heap_t vrna_heap_init(size_t n, vrna_heap_cmp_f cmp, vrna_heap_get_pos_f get_entry_pos, vrna_heap_set_pos_f set_entry_pos, void *data)
Initialize a heap data structure.
void vrna_heap_free(vrna_heap_t h)
Free memory occupied by a heap data structure.
size_t(* vrna_heap_get_pos_f)(const void *a, void *data)
Retrieve the position of a particular heap entry within the heap.
Definition heap.h:76
const void * vrna_heap_top(vrna_heap_t h)
Get the object at the root of the heap.
struct vrna_heap_s * vrna_heap_t
An abstract heap data structure.
Definition heap.h:40
void(* vrna_heap_set_pos_f)(const void *a, size_t pos, void *data)
Store the position of a particular heap entry within the heap.
Definition heap.h:91
void * vrna_heap_pop(vrna_heap_t h)
Pop (remove and return) the object at the root of the heap.
size_t vrna_heap_size(struct vrna_heap_s *h)
Get the size of a heap data structure, i.e. the number of stored elements.
void * vrna_heap_update(vrna_heap_t h, void *v)
Update an arbitrary element within the heap.
int(* vrna_heap_cmp_f)(const void *a, const void *b, void *data)
Heap compare function prototype.
Definition heap.h:59
void vrna_heap_insert(vrna_heap_t h, void *v)
Insert an element into the heap.
void * vrna_heap_remove(vrna_heap_t h, const void *v)
Remove an arbitrary element within the heap.