예제 #1
0
 def __init__(self, size=10):
     self.in_queue = MyQueue(size=size)
     self.out_queue = MyQueue(size=size)
예제 #2
0
class MyQueueStack(object):
    
    def __init__(self, size=10):
        self.in_queue = MyQueue(size=size)
        self.out_queue = MyQueue(size=size)

    def push(self, val):
        self.in_queue.enqueue(val)
        while not self.out_queue.is_empty():
            self.in_queue.enqueue(self.out_queue.dequeue())
        self.in_queue, self.out_queue = self.out_queue, self.in_queue

    def pop(self):
        self.out_queue.dequeue()

    def is_empty(self):
        return self.in_queue.is_empty() and self.out_queue.is_empty()

    def is_full(self):
        return self.in_queue.is_full() or self.out_queue.is_full()