我正在尝试为我创建的名为 Event 的类设置优先级队列。在我尝试此操作之前的 2 行中,我设置了 2 个其他优先级队列,它们似乎工作正常,但在第 3 行出现错误。有什么建议么?
class Event{
enum eventType { Arrival, CPUburstCompletion, IOcompletion, TimerExpired };
double time; // Defined as time units since the start of the simulation
};
vector<process> processTable;
int CPU;
int IO;
priority_queue< int, vector<int> > readyQueue;
priority_queue< int, vector<int> > IO_Queue;
priority_queue< Event, vector<Event> > eventQueue;
我的 Event 类中没有比较器功能。我把它放进去,但我仍然得到一个错误。我没有正确编写比较器吗?
class Event{
enum eventType { Arrival, CPUburstCompletion, IOcompletion, TimerExpired };
double time; // Defined as time units since the start of the simulation
bool operator()(Event& e1, Event& e2){
if (e1.time < e2.time){
return true;
}
else{
return false;
}
}
};
vector<process> processTable;
int CPU;
int IO;
priority_queue< int, vector<int> > readyQueue;
priority_queue< int, vector<int> > IO_Queue;
priority_queue< Event, vector<Event> > eventQueue;