python通过heapq实现的heap类,pythonheapqheap类,import heapq


import heapqclass 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)

评论关闭