STL数组处理常用函数

reverse(a,a+n)反转

sort(a,a+n,cmp)排序

unique(a,a+n,cmp)对于有序集合进行去重,返回新数组最后一个元素的指针

next_permutatoin(a,a+n,cmp)下一个排列

make_heap(a,a+n,cmp),sort_heap(a,a+n,cmp),pop_heap(a,a+n,cmp),push_heap(a,a+n,cmp)与堆有关的四个函数

上例中cmp表示自定义的比较函数

bool cmp(const Node&m,const Node&n);

用和堆有关的函数自定义优先队列

struct  PreQ{
    int a[qsz];
    int sz;
    void init(){
        sz = 0;
    }
    void enq(int x){
        a[sz++] = x;
        push_heap(a, a + sz);
    }
    int deq(){
        pop_heap(a, a + sz);
        return a[--sz];
    } 
}q;
原文地址:https://www.cnblogs.com/weiyinfu/p/4889664.html