实现队列的基本操作(数据结构)-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
posted @ 2020-09-22 19:05  程序猿-悟空  阅读(253)  评论(0编辑  收藏  举报