5 #ifndef DSALGLIB_HEAP_H 6 #define DSALGLIB_HEAP_H 18 void _reheapup(
long long int index)
22 long long int parent=(index-1)/2;
23 if(objs[parent]<objs[index])
25 swapit(objs[parent],objs[index]);
31 void _reheapdown(
long long index)
34 if(index>=0&&index<count)
36 long long int lc=2*index+1,rc=2*index+2,large;
45 if(objs[index]<objs[large])
47 swapit(objs[index],objs[large]);
77 objs[0]=objs[count-1];
119 long long int parent=(index-1)/2;
120 if(objs[index]<objs[parent])
122 swapit(objs[parent],objs[index]);
132 if(index>=0&&index<count)
134 long long int lc=2*index+1,rc=2*index+2,less;
140 if(objs[rc]<objs[lc])
143 if(objs[less]<objs[index])
145 swapit(objs[index],objs[less]);
175 objs[0]=objs[count-1];
210 #endif //DSALGLIB_HEAP_H
void resize(long long int newsize)
void traverse(void(fun)(type obj))
void _reheapup(array< type > objs, long long int index)
void _reheapdown(array< type > objs, long long index, long long int last)
void push_back(type param)
maxheap(long long int size=0)
minheap(long long int size=0)
void traverse(void(fun)(type obj))