zoukankan      html  css  js  c++  java
  • 变序性算法

    代码
    reverse(beg,end);
    reverse_copy(sourcebeg,sourceend,destbeg);

    旋转元素次序:
    rotate(beg,newbeg,end);
    将beg
    -end元素旋转,然后newbeg成为第一个元素

    rotate_copy(beg,newbeg,end,destbeg);
    将beg
    -end的元素旋转复制到destbeg里面,并且使newbeg成为第一个元素

    排列元素:
    bool next_permutation(beg,end);
    bool prev_permutation(beg,end);
    改变元素次序,符合下一个排列次序
    改变元素词语,符合上一个排列次序


    重拍元素:
    random_abuffle(beg,end);
    random_abuffle(beg,end,op);
    第一个随机打乱beg
    -end的元素次序
    第二个用op打乱beg
    -end的元素次序

    向前搬移元素:
    partition(begin,end,op);
    stable_partition(beg,end,op);

    排序:

    sort(begin,end);

    sort(begin,end,op);

    stable_sort(beg,end);

    stable_sort(beg,end,op);

    局部排序:

    partial_sort(begin,sortend,end);

    partial_sort(begin,sortend,end,op);

    对begin-end进行排序,使begin-sortend变成有序

    partial_sort_copy(sourcebegin,sourceend,destbeg,destend);

    partial_sort_copy(sourcebegin,sourceend,destbeg,destend,op);

    根据第n个元素排序:

    nth_element(beg,nth,end);

    nth_element(beg,nth,end,op);

    heap排序:

    make_heap(beg,end);

    make_head(beg,end,op);

    push_heap(beg,end);

    push_heap(beg,end,op);

    pop_heap(beg,end);

    pop_heap(beg,end,op);

    sort_heap(beg,end);

    sort_heap(beg,end);

  • 相关阅读:
    第八章 对象
    第七章 压缩列表
    第六章 整数集合
    Java中的Unsafe
    站在Java的角度看LinkedList
    Java内部类详解
    浅析Java中的final关键字
    ConcurrentHashMap
    阻塞队列
    线程池的使用和实现
  • 原文地址:https://www.cnblogs.com/linyilong3/p/1847703.html
Copyright © 2011-2022 走看看