]> code.communitydata.science - rises_declines_wikia_code.git/blob - mediawiki_dump_tools/Mediawiki-Utilities/mw/util/heap.py
Initial commit
[rises_declines_wikia_code.git] / mediawiki_dump_tools / Mediawiki-Utilities / mw / util / heap.py
1 import heapq
2
3
4 class Heap(list):
5     def __init__(self, *args, **kwargs):
6         list.__init__(self, *args, **kwargs)
7         heapq.heapify(self)
8
9     def pop(self):
10         return heapq.heappop(self)
11
12     def push(self, item):
13         heapq.heappush(self, item)
14
15     def peek(self):
16         return self[0]
17
18     def pushpop(self, item):
19         return heapq.heappushpop(self, item)
20
21     def poppush(self, itemp):
22         return heapq.replace(self, item)

Community Data Science Collective || Want to submit a patch?