原问题:
Implement the Queue ADT, using a list such that the rear of the queue is at the end of the list
class Queue:
def init(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0,item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
q=Queue()
q.enqueue(4)
q.enqueue('dog')
q.enqueue(True)
print(q.size())
print q.dequeue()
print(q.size())