下边代码是关于python通过heapq实现的heap类的代码。
import heapq
class heap(list) :
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)