pq.py

来自「idel虚拟机源码」· Python 代码 · 共 21 行

PY
21
字号
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 + =
减小字号Ctrl + -
显示快捷键?