# -*- coding:utf-8 -*- class Queue(): #初始化隊列 def __init__(self,size): self.queue=[] self.size=size self.tail=0 #判斷隊列是否爲滿,爲滿返回True def Full(self): if self.tail==self.size: return True else: return False #判斷隊列是否爲空,爲空返回True def Empty(self): if self.tail==0: return True else: return False #進隊 def queuein(self,content): if self.Full(): print 'The queue is full!' else: self.queue.append(content) self.tail+=1 #出隊 def queueout(self): if self.Empty(): print 'The queue is empty!' return None else: content=self.queue[0] self.queue.pop(0) self.tail-=1 return content #遍歷隊列 def queueall(self): if self.Empty(): print 'The queue is empty!' else: for i in range(0,self.tail): print self.queue[i]