Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 17, 2022
1 parent e1eec78 commit 5be31be
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions priorityQueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ type item struct {
// A priorityQueue implements heap.Interface and holds Items.
type priorityQueue []*item

func (pq priorityQueue) Len() int { return len(pq) }
func (pq *priorityQueue) Len() int { return len(*pq) }

func (pq priorityQueue) Less(i, j int) bool {
func (pq *priorityQueue) 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 priorityQueue) Swap(i, j int) {
pq[i], pq[j] = pq[j], pq[i]
pq[i].index = i
pq[j].index = j
func (pq *priorityQueue) Swap(i, j int) {
(*pq)[i], (*pq)[j] = (*pq)[j], (*pq)[i]
(*pq)[i].index = i
(*pq)[j].index = j
}

// Push ...
Expand Down

0 comments on commit 5be31be

Please sign in to comment.