返回
作用:倒置或调换区间元素的位置
声明:
#include <algorithm>
template <class biDirectionalItr>
void reverse(biDirectionalItr first, biDirectionalItr last);
template <class biDirectionalItr, class outputItr>
outputItr reverse_copy(biDirectionalItr first, biDirectionalItr last,outputItr destFirst);
template <class forwardItr>
void rotate(forwardItr first, forwardItr newFirst, forwardItr last);
template <class forwardItr, class outputItr>
outputItr rotate_copy(forwardItr first, forwardItr middle, forwardItr middle,last,outputItr destFirst);
示例代码:
#include <iostream>
#include <list>
#include <string>
#include <numeric>
#include <iterator>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
int temp[10] = {1,3,5,7,9,0,2,4,6,8};
list<int> intList(temp,temp+10);
list<int> resultList;
list<int>::iterator listItr;
ostream_iterator<int> screen(cout," ");
cout << "intList" << endl;
copy(intList.begin(),intList.end(),screen);
cout << endl;
// 倒置
reverse(intList.begin(),intList.end());
cout << "intList" << endl;
copy(intList.begin(),intList.end(),screen);
cout << endl;
// reverse_copy
reverse_copy(intList.begin(),intList.end(),back_inserter(resultList));
cout << "resultList:" << endl;
copy(resultList.begin(),resultList.end(),screen);
cout << endl;
listItr = intList.begin();
listItr++;
listItr++;
cout << "intList before ratete" << endl;
copy(intList.begin(),intList.end(),screen);
cout << endl;
// rotate
rotate(intList.begin(),listItr,intList.end());
cout << "intList after ratete" << endl;
copy(intList.begin(),intList.end(),screen);
cout << endl;
resultList.clear();
// rotate_copy
rotate_copy(intList.begin(),listItr,intList.end(),back_inserter(resultList));
cout << "intList after ratete_copy" << endl;
copy(intList.begin(),intList.end(),screen);
cout << endl;
cout << "resultList:" << endl;
copy(resultList.begin(),resultList.end(),screen);
cout << endl;
resultList.clear();
// 牛逼闪闪的用法
rotate_copy(intList.begin(),find(intList.begin(),intList.end(),6),intList.end(),back_inserter(resultList));
cout << "resultList:" << endl;
copy(resultList.begin(),resultList.end(),screen);
cout << endl;
return 0;
}
运行结果:
intList
1 3 5 7 9 0 2 4 6 8
intList
8 6 4 2 0 9 7 5 3 1
resultList:
1 3 5 7 9 0 2 4 6 8
intList before ratete
8 6 4 2 0 9 7 5 3 1
intList after ratete
4 2 0 9 7 5 3 1 8 6
分享到:
相关推荐
用于三维光学形貌扫描完成后,生成的stl文件的读取,并形成俯视投影云图
stlshow_stl分层_STL分层_stlmatlab_STL切片_stl分层_源码.rar.rar
最新的STL源码,最新的STL源码,最新的STL源码
NX二次开发-UFUN导出STL函数UF_STD_put_solid_in_stl_file博客文章源代码
上传stl文件,等到模型的体积、尺寸等参数
西门子S7-300语句表 STL 实例源代码
stlshow_stl分层_STL分层_stlmatlab_STL切片_stl分层.zip
VC++利用动态连接库开发的读取STL格式文件的界面,可鼠标点选,旋转物体,有需要的朋友可以下载
C++读取STL文件,输出所有三角形的顶点坐标
用于STL文件读取与显示的C语言程序,简单方便实用。
stl转换,能够有效的将matlab 转化为stl文件,用于3DMAX的绘图
STL文件读取程序(Matlab):可以将ASCII格式的的STL文件中的数据点信息及网格拓扑信息读出,并显示在屏幕上
读取 点云数据 STL 文件 分块化编程
打开stl文件,将其还原为3d实体并在3d场景中显示。同时,在数组中显示3d顶点xyz和法向量。点击模拟来观察3d恢复过程。
看STL文件的小软件,可以自由的实现旋转,等功能,现在只是一小部分,以后会发后面的
在vb中读入stl格式的文件。对于机械专业的三维仿真的有用。
基于VC++和OpenGL的STL文件读取显示STL是三维模型常用的文件格式。对STL文件进行读取和显示,是对模型进行后续操作的前提。在对STL文件格式进行详细分析的基础上,以VC+-I-作为开发平台
读取STL格式文件代码,通过建表简化拓扑结构,获取模型的最大值,最小值等参数。
09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板09_07_IO_STL标准模板...
c++ STL source code, hash and vector etc