sort对第三个参数的使用
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时,第二个参数会去堆顶
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了