mirror of
https://github.com/zhm-real/PathPlanning.git
synced 2026-08-30 09:00:47 +08:00
update queue
This commit is contained in:
@@ -55,24 +55,8 @@ class QueuePrior:
|
||||
def put(self, item, priority):
|
||||
heapq.heappush(self.queue, (priority, item)) # reorder x using priority
|
||||
|
||||
def update(self, item, priority):
|
||||
count = 0
|
||||
for (p, x) in self.queue:
|
||||
if x == item:
|
||||
self.queue[count] = (priority, item)
|
||||
break
|
||||
count += 1
|
||||
|
||||
def get(self):
|
||||
return heapq.heappop(self.queue)[1] # pop out the smallest item
|
||||
|
||||
def enumerate(self):
|
||||
return self.queue
|
||||
|
||||
def remove(self, item):
|
||||
for x in self.queue:
|
||||
if item == x[1]:
|
||||
self.queue.remove(x)
|
||||
|
||||
def top_key(self):
|
||||
return self.queue[0][0]
|
||||
|
||||
Reference in New Issue
Block a user