本文整理汇总了Python中priorityQueue.PriorityQueue.empty方法的典型用法代码示例。如果您正苦于以下问题:Python PriorityQueue.empty方法的具体用法?Python PriorityQueue.empty怎么用?Python PriorityQueue.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类priorityQueue.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: color_most_constrained_first
# 需要导入模块: from priorityQueue import PriorityQueue [as 别名]
# 或者: from priorityQueue.PriorityQueue import empty [as 别名]
def color_most_constrained_first(graphs, color):
global spills, unspillable, num_unused, used_registers
#print 'starting color_most_constrained_first'
for v in graphs.vertices():
used_registers[v] = set([])
num_unused[v] = len(registers) - len(used_registers[v])
left = set(graphs.vertices()) - set(reserved_registers) - set(registers)
queue = PriorityQueue(left, avail_reg_then_unspill)
while not queue.empty():
v = queue.pop()
if debug:
print 'next to color is ' + v
if v not in color.keys():
c = choose_color(v, color, graphs,False)
color[v] = c
for u in graphs.interferes_with(v):
#if u in graphs.vertices():
queue.update(u)
used_registers[u] |= set([c])
num_unused[u] = len(registers) - len(used_registers[u])
if not is_reg(c):
spills += 1
return color
示例2: __init__
# 需要导入模块: from priorityQueue import PriorityQueue [as 别名]
# 或者: from priorityQueue.PriorityQueue import empty [as 别名]
class Sim:
def __init__(self):
self.q = PriorityQueue()
self.time = 100
self.nodes = {}
self.actors = []
self.done = False
def add_actor(self, actor):
actor.sim = self
self.actors.append(actor)
def at(self, event):
if event.time < self.time:
print "ERROR, time warp"
else:
self.q.put(event, event.time)
def process(self):
while not self.q.empty():
event = self.q.get()
self.time = event.time
try:
(result, actor) = event.process(self)
actor.send(result)
except StopIteration:
pass
print "Sim done"
def prime(self):
for a in self.actors:
a.prime()
def go(self):
self.prime()
self.process()