⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventlist.h

📁 datastucutre and algorithms, application, in C
💻 H
字号:
// event list class used in machine scheduling

#ifndef eventList_
#define eventList_

#include "myExceptions.h"

using namespace std;

class eventList
{
   public:
      eventList(int theNumMachines, int theLargeTime)
      {// Initialize finish times for m machines.
         if (theNumMachines < 1)
            throw illegalParameterValue
                  ("number of machines must be >= 1");
         numMachines = theNumMachines;
         finishTime = new int [numMachines + 1];
   
         // all machines are idle, initialize with
         // large finish time
         for (int i = 1; i <= numMachines; i++)
            finishTime[i] = theLargeTime;
      }
      
      int nextEventMachine()
      {// Return machine for next event.
      
         // find first machine to finish, this is the
         // machine with smallest finish time
         int p = 1;
         int t = finishTime[1];
         for (int i = 2; i <= numMachines; i++)
            if (finishTime[i] < t)
            {// i finishes earlier
               p = i;
               t = finishTime[i];
            }
         return p;
      }
   
      int nextEventTime(int theMachine)
      {return finishTime[theMachine];}
   
      void setFinishTime(int theMachine, int theTime)
      {finishTime[theMachine] = theTime;}
   private:
      int* finishTime;   // finish time array
      int numMachines;   // number of machines
};
#endif

⌨️ 快捷键说明

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