00001 00005 00006 #ifndef _HEAP_H_ 00007 #define _HEAP_H_ 00008 00009 class InfoRecord; 00010 00011 class heapRecord 00012 { public: 00013 short deleted; // boolean 00014 InfoRecord *info; 00015 }; 00016 00017 class heapIterator{ 00018 public: 00019 int next; 00020 }; 00021 00022 class minHeap 00023 { 00024 private: 00025 heapRecord *h; 00026 int count; 00027 int size; 00028 void swap(int i, int j) { 00029 heapRecord temp = h[i]; 00030 h[i] = h[j]; 00031 h[j] = temp; 00032 } 00033 00034 public: 00035 minHeap(int size); 00036 ~minHeap(); 00037 int numElements() { return count; } 00038 int insert(InfoRecord *); 00039 InfoRecord *deleteMin(); 00040 InfoRecord *iterator(heapIterator *); 00041 InfoRecord *next(heapIterator *); 00042 void update(InfoRecord *); 00043 private: 00044 int least(int a, int b, int c); 00045 void update(int index); 00046 }; 00047 00048 class maxHeap 00049 { 00050 private: 00051 heapRecord *h; 00052 int count; 00053 int size; 00054 00055 void swap(int i, int j) { 00056 heapRecord temp = h[i]; 00057 h[i] = h[j]; 00058 h[j] = temp; 00059 } 00060 00061 public: 00062 maxHeap(int size); 00063 ~maxHeap(); 00064 int numElements(); 00065 int insert(InfoRecord *); 00066 InfoRecord *deleteMax(); 00067 InfoRecord *iterator(heapIterator *); 00068 InfoRecord *next(heapIterator *); 00069 }; 00070 00071 00072 #endif /* _HEAP_H_ */ 00073