C++map使用

#include <boost/date_time.hpp>
#include <boost/timer.hpp>
#include <vector>
#include <map>
#include <iostream>
#include "IPermanceServiceShare.h"
using namespace boost;
using namespace std;
using namespace boost::gregorian;

void main()
{

timer tm;
map<date, vector<PERSON> *> mpList;
date dtStartDate = from_undelimited_string("19880612");
date dtEndDate = from_undelimited_string("20130615");

for (date tem = dtStartDate; tem <= dtEndDate; tem += days(1))
{
vector<PERSON> *pvcPerson = new vector<PERSON>();
mpList.insert(pair<date, vector<PERSON> *>(tem, pvcPerson));
}

map<date, vector<PERSON> *>::iterator tem;

PERSON per1;
//赋值
for (tem = mpList.begin(); tem != mpList.end(); ++tem)
{
per1.strName = "甘全福";
per1.nAge = 24;

tem->second->push_back(per1);
per1.strName = "李刚";
per1.nAge = 35;
tem->second->push_back(per1);
}

//打印
vector<PERSON>::iterator vcTem;
for (tem = mpList.begin(); tem != mpList.end(); ++tem)
{
cout << to_iso_string(tem->first) << endl;;
for (vcTem = tem->second->begin(); vcTem != tem->second->end(); ++vcTem)
{
cout << vcTem->strName << " " << vcTem->nAge << endl;
}

}

double duration;
duration = tm.elapsed();
cout << "总耗时:" << duration << "总记录:" << mpList.size() << endl;

for (tem = mpList.begin(); tem != mpList.end(); ++tem)
{
delete tem->second;
}

int wait;
cin >> wait;
}

原文链接: https://www.cnblogs.com/ganquanfu2008/p/3157068.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++map使用

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/93543

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月10日 上午2:12
下一篇 2023年2月10日 上午2:13

相关推荐