实现队列的基本操作(数据结构)-python版
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