mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化优先队列-Priority值越大,优先级越高
This commit is contained in:
@@ -17,7 +17,7 @@ func (pq PriorityQueueSlice) Len() int { return len(pq) }
|
|||||||
|
|
||||||
func (pq PriorityQueueSlice) Less(i, j int) bool {
|
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.
|
// 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) {
|
func (pq PriorityQueueSlice) Swap(i, j int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user