我目前有一個隊列,它保存用戶指定數量的結構,稱爲進程。過程由一個pid,爆發和到達組成。我想在抵達時對隊列進行排序,但我並不知道從哪裏開始。下面是一些僞代碼來幫助說明什麼,我想說:對結構隊列排序
struct Process{
int pid;
int burst;
int arrival;
};
void function(int numProcesses){
queue<Process> readyQueue;
// The following loop is a shortened version of my code
for(int i=0; i<numProcesses;i++){
readyQueue.push(aProcess);
}
// This is where I need help!
// sort(readyQueue);
}
我會很感激的人誰可以點我在正確的方向上如何做到這一點,或者如果它甚至有可能的。謝謝!
他希望進程按到達順序排序 – billz