00001 00025 #ifndef _HEAPINT 00026 #define _HEAPINT 00027 00028 /*---------------------------------------------------------------------------*/ 00029 /* Nested includes */ 00030 /*---------------------------------------------------------------------------*/ 00031 #include "heap.h" 00032 00033 00034 /*---------------------------------------------------------------------------*/ 00035 /* Constant declarations */ 00036 /*---------------------------------------------------------------------------*/ 00037 00038 00039 /*---------------------------------------------------------------------------*/ 00040 /* Stucture declarations */ 00041 /*---------------------------------------------------------------------------*/ 00042 00051 struct HeapSlot { 00052 long key; 00053 void *item; 00054 }; 00055 00056 00064 struct Heap { 00065 int length; 00066 int nitems; 00067 struct HeapSlot *slots; 00068 int (*compare)(const void *, const void *); 00069 }; 00070 00071 00072 /*---------------------------------------------------------------------------*/ 00073 /* Type declarations */ 00074 /*---------------------------------------------------------------------------*/ 00075 00076 00077 /*---------------------------------------------------------------------------*/ 00078 /* Variable declarations */ 00079 /*---------------------------------------------------------------------------*/ 00080 00081 00082 /*---------------------------------------------------------------------------*/ 00083 /* Macro declarations */ 00084 /*---------------------------------------------------------------------------*/ 00085 00097 #define PARENT(i) (((i)-1)>>1) 00098 00106 #define LEFT(i) (((i)<<1)+1) 00107 00115 #define RIGHT(i) (((i)+1)<<1) 00116 00124 #define ITEM(p,i) ((p)[i].item) 00125 00133 #define KEY(p,i) ((p)[i].key) 00134 00135 00138 /*---------------------------------------------------------------------------*/ 00139 /* Function prototypes */ 00140 /*---------------------------------------------------------------------------*/ 00141 00144 #endif /* _HEAPINT */