cutil/oldheap.h

Go to the documentation of this file.
00001 
00019 #ifndef   HEAP_H
00020 #define   HEAP_H
00021 
00022 /* =================
00023           Include Files and Type Defines
00024  ==================== */
00025 #include "general.h"
00026 #include "cutil.h"
00027 
00029 #define HEAPFULL      3000
00030 
00031 #define OK          0
00032 #define EMPTY -1
00033 
00038 typedef struct
00039 {
00040   FLOAT32 Key;
00041   void *Data;
00042 } HEAPENTRY;
00043 
00048 typedef struct
00049 {
00050   INT32 Size;
00051   INT32 FirstFree;
00052   HEAPENTRY Entry[1];
00053 } HEAP;
00054 
00055 /* =================
00056             Macros
00057  ==================== */
00058 #define           FreeHeap(H) memfree(H)
00059 #define           MaxSizeOfHeap(H)  (H->Size)
00060 #define           SizeOfHeap(H)   (H->FirstFree - 1)
00061 #define           InitHeap(H)   (H->FirstFree = 1)
00062 #define           HeapFull(H)   ((H)->FirstFree > (H)->Size)
00063 #define           HeapEmpty(H)    ((H)->FirstFree <= 1)
00064 
00074 #define           HeapKeyFor(H,E)   ((H)->Entry[(E)+1].Key)
00075 #define           HeapDataFor(H,E)  ((H)->Entry[(E)+1].Data)
00076 
00077 /* =================
00078           Public Function Prototypes
00079  ==================== */
00080 HEAP *MakeHeap(int Size); 
00081 
00082 int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr); 
00083 
00084 int HeapPopWorst(HEAP *Heap, FLOAT32 *Key, void *out_ptr); 
00085 
00086 void HeapPush(HEAP *Heap, FLOAT32 Key, void *Data); 
00087 
00088 void HeapStore(HEAP *Heap, HEAPENTRY *Entry); 
00089 
00090 int GetTopOfHeap(HEAP *Heap, HEAPENTRY *Entry); 
00091 
00092 void FreeHeapData(HEAP *Heap, void_dest destructor); 
00093 
00094 /*
00095 #if defined(__STDC__) || defined(__cplusplus)
00096 # define        _ARGS(s) s
00097 #else
00098 # define        _ARGS(s) ()
00099 #endif*/
00100 
00101 /* heap.c
00102 HEAP *MakeHeap
00103     _ARGS((int Size));
00104 
00105 int HeapPop
00106     _ARGS((HEAP *Heap,
00107   FLOAT32 *Key,
00108   char **Data));
00109 
00110 int HeapPopWorst
00111     _ARGS((HEAP *Heap,
00112   FLOAT32 *Key,
00113   char **Data));
00114 
00115 void HeapPush
00116     _ARGS((HEAP *Heap,
00117   FLOAT32 Key,
00118   char *Data));
00119 
00120 void HeapStore
00121     _ARGS((HEAP *Heap,
00122   HEAPENTRY *Entry));
00123 
00124 int GetTopOfHeap
00125     _ARGS((HEAP *Heap,
00126   HEAPENTRY *Entry));
00127 
00128 void FreeHeapData
00129     _ARGS((HEAP *Heap,
00130   void (*Deallocator )()));
00131 
00132 #undef _ARGS
00133 */
00134 #endif

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1