4141WHITE = (255 , 255 , 255 )
4242
4343
44- # noinspection PyMissingOrEmptyDocstring
4544class AStarQueue :
4645 """
4746 A* Queue.
@@ -51,17 +50,19 @@ def __init__(self) -> None:
5150 self .myheap = []
5251
5352 def show (self ):
53+ """Show the heap."""
5454 return self .myheap
5555
5656 def push (self , priority , distance , node ) -> None :
57+ """Put the node into heap."""
5758 heapq .heappush (self .myheap , (priority , distance , node ))
5859
5960 def pop (self ):
61+ """Remove the heap item and return it."""
6062 priority , distance , node = heapq .heappop (self .myheap )
6163 return priority , distance , node
6264
6365
64- # noinspection PyMissingOrEmptyDocstring
6566class PriorityQueue :
6667 """
6768 Priority Queue.
@@ -71,17 +72,19 @@ def __init__(self) -> None:
7172 self .myheap = []
7273
7374 def show (self ):
75+ """Show the heap."""
7476 return self .myheap
7577
7678 def push (self , priority , node ) -> None :
79+ """Put the node into heap."""
7780 heapq .heappush (self .myheap , (priority , node ))
7881
7982 def pop (self ):
83+ """Remove the heap item and return it."""
8084 priority , node = heapq .heappop (self .myheap )
8185 return priority , node
8286
8387
84- # noinspection PyMissingOrEmptyDocstring
8588class PrioritySet :
8689 """
8790 Create a priority queue that doesn't add duplicate nodes.
@@ -92,14 +95,17 @@ def __init__(self) -> None:
9295 self .myset = set ()
9396
9497 def show (self ):
98+ """Show the heap."""
9599 return self .myheap
96100
97101 def push (self , priority , node ) -> None :
102+ """Put the node into heap."""
98103 if node not in self .myset :
99104 heapq .heappush (self .myheap , (priority , node ))
100105 self .myset .add (node )
101106
102107 def pop (self ):
108+ """Remove the heap item and return it."""
103109 priority , node = heapq .heappop (self .myheap )
104110 self .myset .remove (node )
105111 return priority , node
0 commit comments