Created
May 10, 2016 14:42
-
-
Save tiagovizoto/e085f06f377f4a022b2a47acd015ceaa to your computer and use it in GitHub Desktop.
Fila - Estrutura de Dados em Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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