Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/dabeaz/python-cookbook
/ push
Method
push
src/1/implementing_a_priority_queue/example.py:12–14 ·
view source on GitHub ↗
(self, item, priority)
Source
from the content-addressed store, hash-verified
10
self._index = 0
11
12
def
push(self, item, priority):
13
heapq.heappush(self._queue, (-priority, self._index, item))
14
self._index += 1
15
16
def
pop(self):
17
return
heapq.heappop(self._queue)[-1]
Callers
1
example.py
File · 0.45
Calls
no outgoing calls
Tested by
no test coverage detected