头文件
#include <algorithm>
make_heap(start,end,function) [start,end)
pop_heap(start,end,function) [start,end)->[start,end-1) 根->end-1
push_heap(start,end,function) [start,end-1)->[start,end)调整堆
heap_sort(start,end,function) [start,end) 堆排
// edit by colin
// 20141104
// usage of heap in stl
#include <iostream>
#include <algorithm>
using namespace std;
struct test{
int a;
int b;
int c;
}tt[11];
bool comp(const test &one,const test &two)
{
return one.c < two.c;
}
int main()
{
for(int i=0;i<11;++i)
tt[i].c = i+1;
srand((unsigned)time(NULL));
random_shuffle(&tt[0],&tt[11]);
for(int i=0;i<11;++i)
cout<<tt[i].c<<" ";
cout<<endl;
make_heap(&tt[0],&t