-
Notifications
You must be signed in to change notification settings - Fork 0
/
heap.h
36 lines (23 loc) · 944 Bytes
/
heap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//structure declaration for heap nodes.
struct heapnode{
//Building triplet - building number, execution time and total construction time
int bnum,exec_time,total_time;
struct rbtnode* twin;
};
//Class of heap data structure
class heap{
public:
struct heapnode* root;
int last; // keeps track of last element in the heap array
int size; // keeps track of total size allocated for heap array
heapnode* insert(int, int, int,rbtnode*); // insert a new node into the heap.
struct heapnode* removeMin(); // remove the item from top of the heap ie minimum executed time.
void swapbuilding(struct heapnode* a,struct heapnode* b); // swap two nodes of the heap
void heapify(); // regain heap property
void updateMin(int exec_time); // update exec_time of root node and heapify the structure
heap(int); // constructor declaration
void execute(int); // execute a job
~heap(){ // destructor declaration
delete root;
}
};