heap.h
Go to the documentation of this file.00001 #ifndef HEAPH
00002 #define HEAPH
00003
00004 #include "vector.h"
00005
00043 boolean LessThanID(void *a,void *b,void *userData);
00044
00045
00060 boolean LessThanDouble(void *a,void *b,void *userData);
00061
00062
00077 boolean LessThanPtr(void *a,void *b,void *userData);
00078
00079
00088 typedef struct
00089 {
00090 Tvector data;
00091 boolean hasIDs;
00092 Tvector id2data;
00094 Tvector data2id;
00096 unsigned int last;
00097 boolean (* LessThan)(void*,void*,void*);
00099 void *userData;
00104 } Theap;
00105
00129 void InitHeap(unsigned int ele_size,
00130 void (* Copy)(void *,void*),
00131 void (* Delete)(void *),
00132 boolean (* LessThan)(void *,void *,void *),
00133 void *userData,
00134 boolean hasIDs,
00135 unsigned int max_ele,Theap *heap);
00136
00146 void CopyHeap(Theap *h_dst,Theap *h_src);
00147
00157 unsigned int HeapSize(Theap *heap);
00158
00168 boolean HeapEmpty(Theap *heap);
00169
00179 void AddElement2Heap(unsigned int id,void *e,Theap *heap);
00180
00198 void UpdateHeapElement(unsigned int id,Theap *heap);
00199
00211 void *GetHeapElement(unsigned int i,Theap *heap);
00212
00223 void *GetHeapElementWithID(unsigned int id,Theap *heap);
00224
00236 unsigned int GetHeapPosition(unsigned int id,Theap *heap);
00237
00250 void ExtractMinElement(void *e,Theap *heap);
00251
00259 void ResetHeap(Theap *heap);
00260
00268 void DeleteHeap(Theap *heap);
00269
00270 #endif