#include
#include
#include
#include
#include
#include
using namespace std;
#define MAX_BUF_SIZE 1024
typedef struct
{
short int length;
short int type;
int ID;
short int sequence;
short int flag;
}m_header;
typedef struct
{
m_header head;
char XmlMessages[MAX_BUF_SIZE];
}m_message;
////////////////////////////Vector排序函数的定义///////////////////////////
bool vectorCompare(const m_message & m1,const m_message & m2)
{
return m1.head.sequence
int main()
{
m_message * mess;
vector
map
map
m_message mess0;
mess=&mess0;
mess->head.length=4;
mess->head.type=802;
mess->head.sequence=1;
mess->head.ID = 2005;
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == mess->head.ID)
{nm = pIter->second;}
}
if(nm==NULL)
{
vector
nm = &vect;
ml.insert(map
}
(*nm).push_back(mess0);
nm = NULL;
m_message mess1;
mess=&mess1;
mess->head.length=4;
mess->head.type=801;
mess->head.sequence=2;
mess->head.ID = 2005;
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == mess->head.ID)
{nm = pIter->second;}
}
if(nm==NULL)
{
vector
nm = &vect;
ml.insert(map
}
(*nm).push_back(mess1);
nm = NULL;
m_message mess2;
mess=&mess2;
mess->head.length=4;
mess->head.type=801;
mess->head.sequence=3;
mess->head.ID = 2008;
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == mess->head.ID)
{nm = pIter->second;}
}
if(nm==NULL)
{
vector
nm = &vect;
ml.insert(map
}
(*nm).push_back(mess2);
nm = NULL;
m_message mess3;
mess=&mess3;
mess->head.length=4;
mess->head.type=801;
mess->head.sequence=2;
mess->head.ID = 2008;
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == mess->head.ID)
{nm = pIter->second;}
}
if(nm==NULL)
{
vector
nm = &vect;
ml.insert(map
}
(*nm).push_back(mess3);
nm = NULL;
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == 2005)
{
nm = pIter->second;
sort((*nm).begin(),(*nm).end(),vectorCompare);
}
}
for(int i=0;i<(*nm).size();i++)
{
printf("ID:%d,sequence:%d,type:%d\n",(&(*nm).at(i))->head.ID,(&(*nm).at(i))->head.sequence,(&(*nm).at(i))->head.type);
}
(*nm).~vector
for(pIter=ml.begin();pIter!=ml.end();pIter++)
{
if(pIter->first == 2008)
{
nm = pIter->second;
sort((*nm).begin(),(*nm).end(),vectorCompare);
}
}
for(int i=0;i<(*nm).size();i++)
{
printf("ID:%d,sequence:%d,type:%d\n",(&(*nm).at(i))->head.ID,(&(*nm).at(i))->head.sequence,(&(*nm).at(i))->head.type);
}
(*nm).~vector
return 0;
}