Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialeezero committed Nov 22, 2024
1 parent 75989c6 commit eba62c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions qupsy/worklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def __init__(self) -> None:
self.current_set: PriorityQueue[tuple[int, int, Pgm]] = PriorityQueue()
self.overall_set: list[Pgm] = []

def put(self, enqueue: list[Pgm]) -> None:
for element in enqueue:
if element not in self.overall_set:
self.current_set.put((element.cost, element.depth, element))
self.overall_set.append(element)
def put(self, *pgms: Pgm) -> None:
for pgm in pgms:
if pgm not in self.overall_set:
self.current_set.put((pgm.cost, pgm.depth, pgm))
self.overall_set.append(pgm)

def get(self) -> Pgm:
return self.current_set.get_nowait()[2]
Expand All @@ -25,3 +25,6 @@ def show_pq(self) -> None:

def notEmpty(self) -> bool:
return not self.current_set.empty()

def num_pgm_left(self) -> int:
return self.current_set.qsize()

0 comments on commit eba62c7

Please sign in to comment.