job.h

来自「《数据结构、算法与应用》从C++语言应用角度列举了要点」· C头文件 代码 · 共 42 行

H
42
字号
// job class used in machine scheduling

#ifndef job_
#define job_

#include "task.h"
#include "arrayQueue.h"

using namespace std;

struct job
{
   arrayQueue<task> taskQ;   // this job's tasks
   int length;               // sum of scheduled task times
   int arrivalTime;          // arrival time at current queue
   int id;                   // job identifier

   job(int theId = 0)
   {
      id = theId;
      length = 0;
      arrivalTime = 0;
   }

   void addTask(int theMachine, int theTime)
   {
      task theTask(theMachine, theTime);
      taskQ.push(theTask);
   }

   int removeNextTask()
   {// Remove next task of job and return its time.
    // Also update length.
   
      int theTime =  taskQ.front().time;
      taskQ.pop();
      length += theTime;
      return theTime;
   }
};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?