cannot view the data after adding to vector
Dec 16, 2013 at 7:59pm UTC
Dears,
Iam a beginner and I develop using linux g++
Kindly need your support as after creation of 3D vector and adding the Transaction object to it, I can't view the data to use although it is working fine on visual studio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
vector<vector <vector< Transaction> > > Trans2d;
Trans2d.resize(2);
for (int i = 0; i < 2; i++)
{Trans2d[i].resize(TRANS_QUEUE_DEPTH);
for (int j = 0; j< TRANS_QUEUE_DEPTH; j++)
{//Trans[j].resize(2);
Trans2d[i][j].reserve(4);}}
bool MemoryController::addTransaction(Transaction trans)
{
if (WillAcceptTransaction(trans))
{
if ((trans).priority == 1 )
{
DEBUG("== currentClockCycle '" < trans->timeAdded = currentClockCycle;
if ((trans).transtp == "P_MEM_WR_H" || (trans).transtp == "P_MEM_WR_NH" )
{Trans2d[0][0].push_back(trans);
DEBUG("== Trans2d[0][0][0].transtp '" <<Trans2d[0][0][0].transtp<<"' == " );}
else {
Trans2d[0][1].push_back(trans);}
for ( int i = 0; i < Trans2d[0].size(); i++) {
Transaction tmp;
DEBUG("== [i] '" <<i<<"' == " );
//tmp=new Transaction (transType,1,1," ",NULL);
for (int j=1; j< Trans2d[0][i].size(); j ++)
{
DEBUG("== [j] '" <<j<<"' == " );
DEBUG("== Trans2d[0][0][0].transtp '" <<Trans2d[0][0][0].transtp<<"' == " );//the data here appears null
if (Trans2d[0][i][j].transtp == "P_MEM_WR_H" && Trans2d[0][i][j-1].transtp == "P_MEM_WR_NH" )
{ DEBUG("== We need to swap WR H and NH == " );
tmp=Trans2d[0][i][j];
Trans2d[0][i][j]=Trans2d[0][i][j-1];
Trans2d[0][i][j-1]=tmp;
}
else if (Trans2d[0][i][j].transtp == "P_MEM_RD_H" && Trans2d[0][i][j-1].transtp == "P_MEM_RD_NH" )
{ DEBUG("== We need to swap RD H and NH == " );
tmp=Trans2d[0][i][j];
Trans2d[0][i][j]=Trans2d[0][i][j-1];
Trans2d[0][i][j-1]=tmp;
}
else
{DEBUG("== It seems both threads are HRTS ....So Skip== " );
continue ;
}
}
}
return true ;
}
else
{
return false ;
}
}
}
Topic archived. No new replies allowed.