Created
June 19, 2022 03:03
-
-
Save wanderindev/438ac8ea947a10bf33c2c3b3f804ea91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pull(self) -> Union[str, None]: | |
| """ | |
| Return and remove the task with the highest priority. | |
| Since Python's heapq is implemented as a min heap, a | |
| smaller number mean the higher priority, i.e. priority 1 | |
| has a higher priority that priority 2. | |
| Elements with same priority are pulled in the order of | |
| insertion. | |
| """ | |
| if self.is_empty(): | |
| return None | |
| return heapq.heappop(self.pqueue)[2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment