python通过heapq实现的heap类的代码

下边代码是关于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)

猜你喜欢

转载自blog.csdn.net/weixin_44201346/article/details/88998479
今日推荐