Hi. Can someone tell me how to output a two-dimensional priority queue please? In particular I am using an array of priority queues. The method I use to output an array of vectors is not working.
I will show the one that is working (array of vectors):
if(!diskQueues[i].empty())
{
for (int j=0; j<diskQueues[i].size(); j++)
{
cout << setw(0) << diskQueues[i][j].getPid() << setw(6) << " "
<< setw(14) << diskQueues[i][j].getFilename() << setw(14) << diskQueues[i][j].getMemoryStart()
<< setw(14) << diskQueues[i][j].getFileLength() << setw(14) << " - " << diskQueues[i][j].getTau() << endl;
cout << endl;
}
}
Where diskQueues[i] is an array of vectors that was declared as: vector<PCB> diskQueues[9];
This is the one that is not working (array of priority queues):
if( ! dd.pDiskQueues[i].empty() )
{
for (int j=0; j<dd.pDiskQueues[i].size(); j++)
{
PCB process = dd.pDiskQueues[i].top();
cout << setw(0) << dd.pDiskQueues[i][j].getPid() << setw(6) << " "
<< setw(14) << dd.pDiskQueues[i][j].getFilename() << setw(14) << dd.pDiskQueues[i][j].getMemoryStart()
<< setw(12) << dd.pDiskQueues[i][j].getFileLength() << setw(12) << dd.pDiskQueues[i][j].getRW() << setw(8) <<dd.pDiskQueues[i][j].getTau() << dd.pDiskQueues[i][j].getDiskTime()
<< cout << endl;
dd.pDiskQueues[i].pop();
}
}
}
Where pDiskQueues[i] is an array of priority queues that is declared as: priority_queue<PCB> pDiskQueues[9];
This is the error message I'm getting:
[Error] no match for 'operator[]' (operand types are 'std::priority_queue<PCB>' and 'int')
Thank you.