?? pq.py
字號:
import bisectclass PriorityQueue: def __init__(self): self.queue = [] def append(self, data, priority): """Append a new element to the queue according to its priority""" bisect.insort(self.queue, (priority, data)) def pop(self, n): """Pop the highest element of the queue. The n argument is here to follow the standard queue protocol """ return self.queue.pop(0) def contains(self, x): return x in self.queue def population(self): return len(self.queue)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -