Created
February 27, 2014 14:56
-
-
Save zeldani/9251646 to your computer and use it in GitHub Desktop.
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
import Queue | |
class Tarefa(object): | |
def __init__(self, prioridade, descricao): | |
self.prioridade = prioridade | |
self.descricao = descricao | |
print 'Nova tarefa:', descricao | |
return | |
def __cmp__(self, outro): | |
return cmp(self.prioridade, outro.prioridade) | |
q = Queue.PriorityQueue() | |
q.put( Tarefa(3, 'Prioridade media') ) | |
q.put( Tarefa(10, 'Prioridade baixa') ) | |
q.put( Tarefa(1, 'Prioridade alta') ) | |
while not q.empty(): | |
proxima_tarefa = q.get() | |
print 'Processando tarefa:', proxima_tarefa.descricao |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment