Advertisement
davide1409

Queue

Jan 10th, 2020
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. class Queue:
  2.   def __init__(self,size = 100):
  3.   #@param size: int
  4.     self.queue = []
  5.     self.size = size
  6.    
  7.   def In(self,element):
  8.   #@param element: qualsiasi tipo
  9.     if len(self.queue) <= self.size:
  10.       self.queue.append(element)
  11.     else:
  12.       print('Raggiunto limite di memoria')
  13.  
  14.   def Out(self):
  15.     self.queue = self.queue[1:]
  16.  
  17.   def first(self):
  18.   #@return: qualsiasi tipo
  19.     return self.queue[0]
  20.  
  21.   def last(self):
  22.   #@return: qualsiasi tipo
  23.     return self.queue[-1]
  24.    
  25.   def empty(self):
  26.   #@return: bool
  27.     return not self.queue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement