vector查找结构体实例find_if
来源:互联网 发布:免费的linux服务器 编辑:程序博客网 时间:2024/04/29 05:40
</pre><pre name="code" class="cpp">
#include <iostream>#include <string> #include <functional>#include <list> #include <vector>#include <algorithm> using namespace std;typedef struct _tagSyncTable {int nType;//主表类型string strName;//主数据表名string strOrderBy;//排序方式_tagSyncTable(int type, string name = "", string OrderBy = ""){nType = type;strName = name;strOrderBy = OrderBy;}_tagSyncTable(){}}SyncTable;//查找类class FindType{public:bool operator()(SyncTable& dValue){return dValue.nType == m_val.nType;}static void SetSyncTable(SyncTable dval){m_val = dval;}private:static SyncTable m_val;};SyncTable natvalue,destvalue;SyncTable FindType::m_val = natvalue;int main(int argc, char* argv[]){ vector <SyncTable> userList; SyncTable tempnat; SyncTable st;st.nType = 15;st.strName = "t_bas_ShopGoods";st.strOrderBy = "GoodsId";userList.push_back(st);st.nType = 16;st.strName = "t_bas_myCategory";st.strOrderBy = "myCatId";userList.push_back(st);st.nType = 17;st.strName = "t_pos_PresetGoods";st.strOrderBy = "GoodsId";userList.push_back(st); st.nType = 16; FindType::SetSyncTable(st); vector <SyncTable>::iterator it=find_if(userList.begin(), userList.end(), FindType()) ; if(it!=userList.end()) { SyncTable st = *it; cout << "Type=" << st.nType << '\t' << "Name=" << st.strName << '\t' << "OrderBy=" << st.strOrderBy << endl; } return 0;}
0 0
- vector查找结构体实例find_if
- find_if和函数对象结合实现对自定义类型vector的查找 复杂结构体查询某个值
- STL 结构体排序及查找 使用sort及find_if
- 用find_if查找vector内对象的成员
- 用find_if查找vector内对象的成员
- 用find_if查找vector内对象的成员
- STL中vector查找算法find()和find_if()深入比较
- 使用find_if的自定义条件查找vector或map
- vector容器结构体类型查找
- vector 查找/查找和对比结构体元素值
- C++中的vector&find_if
- vector的find_if用法
- STL应用 vector & find_if
- find_if和函数对象结合实现对自定义类型vector的查找
- vector中元素的查找(find_if)与复制(copy)
- STL 查找vector容器中的指定对象:find()与find_if()算法
- find_if和函数对象结合实现对自定义类型vector的查找
- 用find_if查找vector内对象的成员 http://blog.csdn.net/zhongguoren666/article/details/7629610
- java堆栈查找方法之线程篇
- 函数返回值return后的内容不能指向“栈内存”
- js控制元素隐藏显示,显示时不用display=block
- Linux学习笔记2-----Linux OS的文件目录
- springmvc .ibatis注解Configuration$StrictMap.get(Configuration.java:593)
- vector查找结构体实例find_if
- No12-【转】别在最能吃苦的年纪里选择了安逸
- kuangbin带你飞 A 搜索 ——棋盘问题
- 数组
- IE浏览器连不上网电脑无法联网
- Gatling-基于Scala,Akka&Netty的性能测试框架
- 使用hexo时deploy部署网站到github或gitcafe的gitpages时重复输入用户名密码的解决办法
- s3c6410的GPIO驱动总结
- Android下拉/上拉刷新ListView之Android-PullToRefresh