okay i didnt want 2 cuz now i might have to explain the problem but here is my code.... the important parts.. FYI the vector fills correctly from the stream b/c i tested that.
My Struct
Code:
struct Process //Structure will hold all process information from the procces file
{
int procId; // process ID ... 1000.. 1001 etc
string name; // holds the name of the process
int cpuTime; // Total CPU time needed for process
int timeBurst; // Burst for each process
};
and here is my function... i apologize if its distorted .. its hard to make it look normal here.
Code:
void procSched(const vector<Process>& procVector)
{
// totProc is the total number of Proccess that need to run
while (!procVector.empty()) // Continue to process until vector is empty
{
for (size_t j = 0; j < procVector.size(); j++) // Loop through the vecotr
{ // doo scheduling things here.
//output the process information
cout << procVector[j].procId << ' ' << procVector[j].name << ' '
<< procVector[j].cpuTime << ' ' << procVector[j].timeBurst << endl;
if (procVector[j].cpuTime <= 0) // If time is below 0, the process is exhausted
{
procVector.erase(procVector.begin() + j);
}
}
}
}
Its the erase section at the end as u can c that i want out... i want to eliminate that vector incluing the time, the burst, the name etc.