template<typename _RandomAccessIter, typename _Tp, typename _Compare>
void
__unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, _Compare __comp)
{
_RandomAccessIter __next = __last;
--__next;
while (__comp(__val, *__next)) {
*__last = *__next;
__last = __next;
--__next;
}
*__last = __val;
}
bool com(int a, int b)
返回为真时的条件,就是 a排在b前面的条件
struct comp
{
bool operator()(const int &x, const int &y)const
{
return x > y;
}
};
std make_heap
struct heap_cmp {
bool operator() (const heap_item *item1, const heap_item *item2) const {
return item1->key < item2->key;
}
};
堆顶要求是value最大的元素
返回true时,第二个参数,value大
返回true时,第二个参数会去堆顶