heapq是一个很好的堆类,但是其自带的方法不太明确,这里自定义了一个heap类
import heapq class heap(list) : def __init__(self, * pos_arg, ** nam_arg) : list.__init__(self, * pos_arg, ** nam_arg) def pop(self) : return heapq.heappop(self) def push(self, item) : heapq.heappush(self, item) def pushpop(self, item) : return heapq.heappushpop(self, item) def poppush(self, itemp) : return heapq.replace(self, item)