變序性演算法

來源:互聯網
上載者:User
代碼

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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.