Skip to content

Instantly share code, notes, and snippets.

@tiagovizoto
Created May 10, 2016 14:42
Show Gist options
  • Save tiagovizoto/e085f06f377f4a022b2a47acd015ceaa to your computer and use it in GitHub Desktop.
Save tiagovizoto/e085f06f377f4a022b2a47acd015ceaa to your computer and use it in GitHub Desktop.
Fila - Estrutura de Dados em Python
class Fila:
def __init__(self):
self.fila = []
self.tamanho_fila = 0
def push(self, e):
self.fila.append(e)
self.tamanho_fila +=1
def pop(self):
if not self.empty():
self.fila.pop(0)
self.tamanho_fila -= 1
def empty(self):
if self.len_queue == 0:
return True
return False
def length(self):
return self.tamanho_fila
def first(self):
if not self.empty():
return self.fila[0]
return print('Fila Vazia')
q = Fila()
q.first()
q.push(8)
q.push(4)
q.push(2)
q.push(1)
print(q.first())
q.pop()
print(q.first())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment