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;
}

posted @ 2013-06-26 18:37  Predator  阅读(309)  评论(0编辑  收藏  举报