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