Skip to content

Instantly share code, notes, and snippets.

@zeldani
Created February 27, 2014 14:56
Show Gist options
  • Save zeldani/9251646 to your computer and use it in GitHub Desktop.
Save zeldani/9251646 to your computer and use it in GitHub Desktop.
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