C++ Vector 与STL Iterator的使用
来源:互联网 发布:php初学者开发工具 编辑:程序博客网 时间:2024/05/29 14:30
#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(int argc, char *argv[]){ cout<<"STL_TEST"<<endl; vector<int> iv; for(int i=0; i<10; i++) { iv.push_back(i); } vector<int>::iterator rst = find(iv.begin(), iv.end(), 5); if(rst == iv.end()) cout<<"no result"<<endl; else cout<<"got: "<<*rst<<endl; return 0;}
#include <iostream>#include <vector>#include <algorithm>using namespace std;class onec{private: int i; char c; double d; string str;public: onec(int ix, char cx, double dx, string sx) {i = ix; c = cx; d = dx; str = sx;} int showID(void) {return i;} bool operator == (const onec &x) {return (this->i == x.i)&&(this->c == x.c)&&(this->d == x.d)&&(this->str == x.str);}};int main(int argc, char *argv[]){ cout<<"STL_TEST_FIND_CLASS"<<endl; vector<onec> o; for(int i=0; i<10; i++) { o.push_back(onec(i, 'c', i/10, "str")); } int i = 9; onec of(i, 'c', i/10, "str"); vector<onec>::iterator rst2 = find(o.begin(), o.end(), of); /**/ if(rst2 == o.end()) cout<<"no result"<<endl; else cout<<"got: "<<rst2->showID()<<endl; rst2 = o.begin(); cout<<"begin: "<<rst2->showID()<<endl; rst2 = o.end() - 1; cout<<"end: "<<rst2->showID()<<endl; return 0;}
0 0
- C++ Vector 与STL Iterator的使用
- vector与iterator的使用
- vector iterator 的使用
- C++STL中vector的使用
- stl之vector的iterator坑
- vector中迭代器iterator的使用
- STL的vector使用
- STL iterator迭代器的使用
- C++ STL入门教程(2):Vector容器与iterator迭代器
- 有关STL中的vector::iterator
- STL中map、vector的iterator的简单用法
- STL vector的之erase应用iterator
- vector的iterator的错误使用
- vector的iterator的 使用复习
- C++vector 迭代器iterator
- 关于迭代器vector::iterator的使用
- [积累]vector的详细使用, 包括iterator
- Vector和iterator的使用心得
- COM组件的初始化
- When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when
- NSNetService
- final和finally,finalize的区别
- response.setContentType()的作用及参数
- C++ Vector 与STL Iterator的使用
- 图书馆位置管理项目之一:环境搭建(java eclipse tomcat mysql)
- 删除list中符合条件的内容
- js中数组(Array)重排序方法深析
- GCD基本概念和Dispatch Queue
- 视频工具箱和硬件加速
- dubbo的使用总结
- Html+Css 纯CSS实现的导航 (精通CSS高级WEB解决方案)读书笔记
- [solr] - IKAnalyzer 扩展分词库