[Python] python通过heapq实现的heap类 →→→→→进入此内容的聊天室

来自 , 2019-04-19, 写在 Python, 查看 107 次.
URL http://www.code666.cn/view/64f173a4
  1. import heapq
  2.  
  3. class heap(list) :
  4.         def __init__(self, * pos_arg, ** nam_arg) :
  5.                 list.__init__(self, * pos_arg, ** nam_arg)
  6.                
  7.         def pop(self) :
  8.                 return heapq.heappop(self)
  9.                
  10.         def push(self, item) :
  11.                 heapq.heappush(self, item)
  12.                
  13.         def pushpop(self, item) :
  14.                 return heapq.heappushpop(self, item)
  15.                
  16.         def poppush(self, itemp) :
  17.                 return heapq.replace(self, item)
  18.        
  19.  
  20. #//python/8911

回复 "python通过heapq实现的heap类"

这儿你可以回复上面这条便签

captcha