fahadkalil

fila_encadeada_24092020

Sep 24th, 2020 (edited)
1,569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. from lse import LSE, Nodo
  2. ## conferir o nome do arquivo que possui a classe LSE e Nodo
  3.  
  4. class FilaEncadeada:
  5.     def __init__(self):
  6.         self.fila = LSE()
  7.    
  8.     def enqueue(self, item): # enfileirar == inserir fim
  9.         self.fila.inserir_fim(Nodo(item))
  10.  
  11.     def dequeue(self): # desenfileirar == remover inicio
  12.         return self.fila.remover_inicio().dado
  13.  
  14.     def front(self):
  15.         return self.fila.head.dado
  16.  
  17.     def __len__(self):
  18.         return len(self.fila)
  19.  
  20. ## TESTES ##
  21. f = FilaEncadeada()
  22. f.enqueue("Pessoa 1")
  23. f.enqueue("Pessoa 2")
  24. f.enqueue("Pessoa 3")
  25.  
  26. f.dequeue()
  27. #f.dequeue()
  28. #f.dequeue()
  29. print(f.front())
  30.  
  31.  
  32.  
Add Comment
Please, Sign In to add comment