stl排序(240)

以前有笔记,但忘了放哪了,再做一次吧

  • stable_sort
  • partial_sort
  • nth_element
  • partition和stable_partition
1
2
3
bool func(const w& l, const w& r) {...}
bool ifunc(const w& c) {...}

partial_sort

只排一部分:`partial_sort(w.begin(),w.beging()+20,w.end(),func)`只对前20个元素排

nth_element

只分界:`nth_element(w.begin(),w.beging()+20,w.end(),func)`
将最后的20个元素放前面,但它不会像前面那个函数,这个函数不会排序,只是单纯放前面

partition

前面俩个只会比较元素,当判断元素属性时呢
`partition(w.begin(), w.end(), ifunc)`功能类似`partial_sort`但比较函数不同
// //