00001
00002
00004 #ifndef EQHEAP_H
00005 #define EQHEAP_H
00006
00008 class HeapNode
00009 {
00010 public:
00012 int subheapsize;
00014 Event *e;
00016 HeapNode *left, *right;
00018 HeapNode() : subheapsize ( 0), e(NULL),left(NULL),right( NULL){ }
00020 HeapNode(Event *ev, int sz, HeapNode *l, HeapNode *r) :
00021 subheapsize(sz), e(ev), left(l), right(r)
00022 {}
00024 ~HeapNode(){if (left) delete left; if (right) delete right; if (e) delete e;}
00026
00028 void insert(Event *e);
00030
00032 void insertDeterministic(Event *e);
00034
00036 HeapNode *conjoin(HeapNode *h);
00038 int remove(eventID evID, POSE_TimeType timestamp);
00040 POSE_TimeType findMax() {
00041 POSE_TimeType max = e->timestamp, leftTS, rightTS;
00042 leftTS = rightTS = POSE_UnsetTS;
00043 if (left) leftTS = left->findMax();
00044 if (right) rightTS = right->findMax();
00045 if (max < leftTS) max = leftTS;
00046 if (max < rightTS) max = rightTS;
00047 return max;
00048 }
00050 void dump();
00052 char *dumpString();
00054
00055 void pup(PUP::er &p);
00057 void sanitize();
00058 };
00059
00061 class EqHeap {
00063 int heapSize;
00064 public:
00066 HeapNode *top;
00068 EqHeap() : heapSize(0),top(NULL){ }
00070 ~EqHeap() { if (top) delete top; }
00072 inline int size() { return heapSize; }
00074 void InsertEvent(Event *e);
00076 void InsertDeterministic(Event *e);
00078
00080 Event *GetAndRemoveTopEvent();
00082
00085 int DeleteEvent(eventID evID, POSE_TimeType timestamp);
00087 inline POSE_TimeType FindMax() {
00088 if (top) return top->findMax();
00089 return POSE_UnsetTS;
00090 }
00092 void dump();
00094 char *dumpString();
00096
00097 void pup(PUP::er &p);
00099 void sanitize();
00100 };
00101
00102 #endif