| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef eslHEAP_INCLUDED |
| 5 |
#define eslHEAP_INCLUDED |
| 6 |
#include <esl_config.h> |
| 7 |
|
| 8 |
#define eslHEAP_INITALLOC 128 |
| 9 |
|
| 10 |
#define eslHEAP_MIN 0 |
| 11 |
#define eslHEAP_MAX 1 |
| 12 |
|
| 13 |
#define ESL_HEAP_PARENT(i) ( ((i)-1) / 2 ) |
| 14 |
#define ESL_HEAP_LEFT(i) ( ((i)*2) + 1 ) |
| 15 |
#define ESL_HEAP_RIGHT(i) ( ((i)+1) * 2 ) |
| 16 |
|
| 17 |
typedef struct esl_heap_s { |
| 18 |
int *idata; |
| 19 |
|
| 20 |
int n; |
| 21 |
int nalloc; |
| 22 |
int maxormin; |
| 23 |
} ESL_HEAP; |
| 24 |
|
| 25 |
extern ESL_HEAP *esl_heap_ICreate (int maxormin); |
| 26 |
extern int esl_heap_GetCount (ESL_HEAP *hp); |
| 27 |
extern int esl_heap_IGetTopVal(ESL_HEAP *hp); |
| 28 |
extern int esl_heap_Reuse (ESL_HEAP *hp); |
| 29 |
extern void esl_heap_Destroy (ESL_HEAP *hp); |
| 30 |
|
| 31 |
extern int esl_heap_IInsert(ESL_HEAP *hp, int val); |
| 32 |
|
| 33 |
extern int esl_heap_IExtractTop(ESL_HEAP *hp, int *ret_val); |
| 34 |
|
| 35 |
extern int esl_heap_IGetTop(ESL_HEAP *hp); |
| 36 |
|
| 37 |
#endif |