00001 #ifndef __MCandidateHeapList__
00002 #define __MCandidateHeapList__
00003
00004
00005
00023 #include <stdio.h>
00024 #include "MPsi2DValue.hpp"
00025
00026 class MCandidateHeapList
00027 {
00028 private:
00029
00030 int nmax;
00031 int n;
00032
00033 MPsi2DValue** heap;
00034
00035 protected:
00036
00037 void reorderUp(int key);
00038 void reorderDown(int key);
00039
00040 void reorder(int akey)
00041 {
00042 reorderUp(akey);
00043 reorderDown(akey);
00044 }
00045
00046 public:
00047
00048 MCandidateHeapList(int maxData);
00049 ~MCandidateHeapList(){ delete[] heap; }
00050
00051 bool isEmpty(){ return n <= 0; }
00052 bool isFull(){ return n == nmax; }
00053
00054 int numberOfData(){ return n; }
00055
00056 MPsi2DValue* getTop(){ return heap[0]; }
00057 MPsi2DValue* get(int i){ return heap[i]; }
00058
00059 void insertData(MPsi2DValue* data);
00060 void removeFirstValue();
00061 void updateData(MPsi2DValue* data);
00062
00063 void output();
00064 };
00065
00066 #endif