赞
踩
class Queue: def __init__(self): self.entries = [] self.length = 0 self.front = 0 def put(self, item): # 入队 self.entries.append(item) self.length += 1 def get(self): # 出队、反转 self.length -= 1 dequeued = self.entries[self.front] self.entries = self.entries[1:] return dequeued def rorate(self): # 反转--队首出队、队尾入队。 for i in range(rotate): self.put(self.get()) def get_front(self): return self.entries[0] def size(self); return self.length
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。