STL map内map
来源:互联网 发布:linux文件系统有哪些 编辑:程序博客网 时间:2024/06/05 23:59
#include "stdafx.h"
#include <string>
#include <iostream>
#include <map>
#include <list>
using namespace std;
#if defined (_MSC_VER)
#pragma warning(disable: 4786)
#endif
struct Node
{
int m_id;
stringm_str;
bool operator<(Node const& _A) const
{
//排序策略,首先按m_id排序,m_id相等则按m_str排序
return m_id < _A.m_id ? true:(m_id>_A.m_id ? false : m_str.compare(_A.m_str)<0);
}
Node(int id,stringstr)
{
m_id=id;
m_str=str;
}
Node(){}
};
int main(int argc, char* argv[])
{
map<int,Node> mapNode,mapNode2;
typedef pair<int,Node> Painr1;
mapNode.insert(Painr1(1,Node(1,"str1")));
mapNode2.insert(Painr1(1,Node(1,"str2")));
map< int, map<int,Node>* >mapList;
typedef pair< int, map<int,Node> *> Painr2;
mapList.insert(Painr2(1,&mapNode));
mapList.insert(Painr2(2,&mapNode2));
map< int, map<int,Node>* >::iterator itemFirst;
map< int, Node>* pNode=NULL;//应该为指针不是迭代器
map< int, Node>::iterator itemSecond;
for(itemFirst=mapList.begin();itemFirst!=mapList.end();++itemFirst)//第一层
{
pNode=itemFirst->second;
for (itemSecond=pNode->begin();itemSecond!=pNode->end();++itemSecond)//第二层
{
cout<<itemSecond->first<<endl;
cout<<itemSecond->second.m_str<<endl;
}
}
return 0;
}
- STL map内map
- STL-map
- stl -map
- stl map
- STL Map
- STL---map
- STL(MAP)
- STL(map)
- STL--map
- STL map
- stl map
- STL map
- STL----map
- stl map
- STL map
- 【STL】map
- STL--map
- STL map
- asp.net数据库操作类(不含存储过程)
- struts1和struts2的比较
- 基于同一ip,多个域名的tomcat的配置
- C++字符串完全指引之一 —— Win32 字符编码
- 学习Java的30个基本概念
- STL map内map
- postgresql源代码的大体框架
- 存钱买镜头
- Flex 开发的一个多文件上传web客户端 Flash Upload
- 【转贴】不同数据库查询前几条记录的SQL语句
- .net开发必备,ASP.net开发必备
- JFreeChart 关于3D柱图
- C语言版的磁盘文件分片归并排序函数 --- 转载
- VB.NET写注册表