Skip to content

Commit

Permalink
drop assumption that priority queue is ordered at initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhue committed Aug 29, 2024
1 parent 5fe41f8 commit 93fb019
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions afsl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ class PriorityQueue(object):

def __init__(self, indices: List[int], values: List[float]):
"""
Initializes the priority queue. Assumes that `values` (and corresponding `indices`) are in ascending order.
Initializes the priority queue.
"""
self.q = [(value, idx) for idx, value in zip(indices, values)][::-1]
self.q = [(value, idx) for idx, value in zip(indices, values)]
heapq.heapify(self.q)

def top(self) -> Element:
"""Returns the top element with the minimum value"""
Expand Down

0 comments on commit 93fb019

Please sign in to comment.