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

📄 event.cpp

📁 简单的 Discrete Event Simulator M/M/K/K queue 含Readme。 可在此基础上开发复杂的仿真程序 请用 tar -xzvf sim.tar.gz 解压
💻 CPP
字号:
#include "event.h"// Insert an Event into an EventList sorted by time index// time - The time at which the event takes place// type - The type of eventvoid EventList::insert(double time, int type){  event_count++;                        // Increment number of events in list.  Event* eptr = new Event(time, type);  if (head == 0) {                      // If EventList is empty,     head = eptr;                        // put new event at head of list.    eptr->next = 0;  }  else if (head->time >= eptr->time) {  // If the event is earlier than    eptr->next = head;                  // all existing events, place it    head = eptr;                        // at the head of the list.  }  else {                                // Otherwise, search for the    Event* eindex;                      // correct location sorted by time.     eindex = head;    while (eindex->next != 0) {      if (eindex->next->time < eptr->time) {        eindex = eindex->next;      }      else {        break;      }    }    eptr->next = eindex->next;    eindex->next = eptr;  }}// Return the Event from the head of the EventListEvent* EventList::get(){  if (event_count == 0) {    return 0;  }  else {    event_count--;    Event* eptr;    eptr = head;    head = head->next;    eptr->next = 0;    return eptr;  }}// Clear all Events from the EventListvoid EventList::clear(){  Event* eptr;  while(head)  {    eptr = head;    head = head->next;    eptr->next = 0;    delete eptr;  }  event_count = 0;}

⌨️ 快捷键说明

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