當前位置: 首頁>>代碼示例>>Python>>正文


Python PriorityQueue.empty方法代碼示例

本文整理匯總了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
開發者ID:parthmishra,項目名稱:p0,代碼行數:31,代碼來源:registerAlloc1.py

示例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()
開發者ID:krohan100,項目名稱:pydssim,代碼行數:38,代碼來源:simdd.py


注:本文中的priorityQueue.PriorityQueue.empty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。