Пример #1
0
class PriorityQueueViewModel:
    def __init__(self):
        self.pq = PriorityQueue()

    def push(self, e):
        self.pq.push(e)

    def top(self):
        return str(self.pq.top())

    def pop(self):
        self.pq.pop()

    def is_empty(self):
        return self.pq.is_empty()
class PriorityQueueViewModel:
    def __init__(self, logger=RealLogger()):
        self.pq = PriorityQueue()
        self.logger = logger
        self.logger.log("Hello pqvm init")

    def push(self, e):
        self.logger.log("PQ push value")
        self.pq.push(e)

    def top(self):
        self.logger.log("PQ get top value")
        return str(self.pq.top())

    def pop(self):
        self.logger.log("PQ pop value")
        self.pq.pop()

    def is_empty(self):
        return self.pq.is_empty()
Пример #3
0
 def test_is_empty_on_creation(self):
     pq = PriorityQueue()
     self.assertTrue(pq.is_empty())
Пример #4
0
 def test_becomes_empty_after_last_pop(self):
     pq = PriorityQueue()
     pq.push(1)
     pq.pop()
     self.assertTrue(pq.is_empty())