sort的用法
来源:互联网 发布:拳皇97 mac 编辑:程序博客网 时间:2024/05/23 01:26
std::sort
template <class RandomAccessIterator> void sort (RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare> void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp);
Sort elements in range
Sorts the elements in the range [first,last)
into ascending order.The elements are compared using
operator<
for the first version, and comp for the second.Equivalent elements are not guaranteed to keep their original relative order (see stable_sort).
Parameters
- first, last
- Random-access iterators to the initial and final positions of the sequence to be sorted. The range used is
[first,last)
, which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
RandomAccessIterator shall point to a type for which swap is properly defined and which is both move-constructible and move-assignable. - comp
- Binary function that accepts two elements in the range as arguments, and returns a value convertible to
bool
.The value returned indicates whether the element passed as first argument is considered to go before the second in the specific strict weak ordering it defines.
The function shall not modify any of its arguments.
This can either be a function pointer or a function object.
//注意第三个参数的解释(我用红色标记的),大意就是如果comp返回的是true,则第一个元素就排在第二个元素前面
阅读全文
0 0
- 【笔记】 sort的用法
- SORT的详细用法
- sort 的用法详解
- sort 命令的用法
- Arrays.sort()的用法
- sort函数的用法
- *sort的一些用法*
- sort的高深用法
- sort的用法
- sort的用法
- sort函数的用法
- STL的sort用法
- Sort函数的用法
- sort函数的用法
- sort的用法
- linux sort的用法
- sort函数的用法
- sort函数的用法
- 页面直接加载进度条
- cocos js中使用腾迅的语音sdk
- 文件,二进制流 互转
- js声明二维数组
- hessian、rmi、dubbo与rpc
- sort的用法
- 自顶向下深入分析Netty(七)--ChannelPipeline和ChannelHandler总述
- Spark学习笔记(1)——Spark架构和主要特征
- 快速排序及时间复杂度分析
- Fast 角点提取c++代码
- Kotlin 设计模式-建造者
- 新到linux服务器硬件配置检查项
- Android IP地址查看
- Junit测试Controller(MockMVC使用),传输@RequestBody数据解决办法