00001 /** \file heap.h 00002 00003 \brief Heap code 00004 00005 */ 00006 00007 #ifndef _HEAP 00008 #define _HEAP 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif 00013 00014 #include "util.h" 00015 #include "array.h" 00016 00017 00018 /** \brief Heap data structure 00019 00020 Based on an array representation of an almost complete binary tree. 00021 00022 */ 00023 00024 struct Heap_t 00025 { 00026 array_t *entryArray; 00027 int (*less) (char *, char *); 00028 }; 00029 00030 typedef struct Heap_t Heap_t; 00031 00032 00033 /**AutomaticStart*************************************************************/ 00034 00035 /*---------------------------------------------------------------------------*/ 00036 /* Function prototypes */ 00037 /*---------------------------------------------------------------------------*/ 00038 00039 extern Heap_t *Heap_Init (int (*)(char *, char *)); 00040 extern Heap_t *Heap_InitN (int (*)(char *, char *), int n); 00041 extern void Heap_Insert (Heap_t *, char *); 00042 extern int Heap_Size (Heap_t *); 00043 extern char *Heap_ReadMax (Heap_t *); 00044 extern void Heap_Heapify (Heap_t *); 00045 00046 /**AutomaticEnd***************************************************************/ 00047 #ifdef __cplusplus 00048 } 00049 #endif 00050 00051 #endif // _HEAP