优化优先队列-Priority值越大,优先级越高

This commit is contained in:
boyce
2021-05-25 10:16:42 +08:00
parent 4653c0394d
commit a16bb6b362

View File

@@ -17,7 +17,7 @@ func (pq PriorityQueueSlice) Len() int { return len(pq) }
func (pq PriorityQueueSlice) Less(i, j int) bool {
// We want Pop to give us the highest, not lowest, Priority so we use greater than here.
return pq[i].Priority < pq[j].Priority
return pq[i].Priority > pq[j].Priority
}
func (pq PriorityQueueSlice) Swap(i, j int) {