Example #1
0
class ERModel(object):
    """Model of a scheduler."""
    def __init__(self):
        self.patients = LinkedPriorityQueue()

    def isEmpty(self):
        """Returns True if there are patients in the model
        or False otherwise. << This didn't make sense. "isEmpty" returns True if empty. fixed in code."""
        if self.patients.size == 0:
            return True
        else:
            return False

    def schedule(self, p):
        """Adds a patient to the schedule."""
        self.patients.add(p)
        #print("Queue Size: ", self.queue.size)   used for traceback
        #print(self.isEmpty())   used for traceback

    def treatNext(self):
        """Returns the patient treated or None if there are none."""
        if self.isEmpty():
            return None
        else:
            temp = self.patients.pop()
            #print("Queue Size: ",  self.queue.size)   used for traceback
            #print(self.isEmpty())   used for traceback
            return temp
Example #2
0
class ERModel(object):
    """ERmodle"""
    def __init__(self):
        self._queue = LinkedPriorityQueue()

    def isEmpty(self):
        return self._queue.isEmpty()

    def schedule(self, patient):
        self._queue.add(patient)

    def treatNext(self):
        patient = self._queue.pop()
        return patient
Example #3
0
class ERModel(object):
    """模型调度器"""
    def __init__(self):
        self._patients_queue = LinkedPriorityQueue()

    def isEmpty(self):
        return self._patients_queue.isEmpty()

    def schedule(self, patient):
        """增加一个病人"""
        self._patients_queue.add(patient)

    def treat_next(self):
        """删除队头节点"""
        return self._patients_queue.pop()
Example #4
0
class ERModel(object):
    """Model of a scheduler."""
    def __init__(self):
        self._patients = LinkedPriorityQueue()

    def isEmpty(self):
        """Returns True if there are patients in the model
        or False otherwise."""
        return self._patients.isEmpty()

    def schedule(self, p):
        """Adds a patient to the schedule."""
        self._patients.add(p)

    def treatNext(self):
        """Returns the patient treated or None if there are none."""
        if self._patients.isEmpty():
            return None
        else:
            return self._patients.pop()
Example #5
0
class ERModel(object):
    """Model of a scheduler."""

    def __init__(self):
        self._patients = LinkedPriorityQueue()

    def isEmpty(self):
        """Returns True if there are patients in the model
        or False otherwise."""
        return self._patients.isEmpty()

    def schedule(self, p):
        """Adds a patient to the schedule."""
        self._patients.add(p)

    def treatNext(self):
        """Returns the patient treated or None if there are none."""
        if self._patients.isEmpty():
            return None
        else:
            return self._patients.pop()
Example #6
0
 def treatNext(self):
     """Returns the patient treated or None if there are none."""
     LinkedPriorityQueue.pop(self)