用python实现双端队列
class Deque:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == 0
def addFront(self, item):
self.items.append(item)
def addRear(self, item):
self.items.insert(0, item)
def removeFront(self):
return self.items.pop()
def removeRear(self):
return self.items.pop(0)
def size(self):
return len(self.items)
s = Deque()
print(s.isEmpty())
s.addRear(3)
s.addFront(4)
s.removeFront()