priority queue implementation in golang
A generic priority queue implementation over a max heap.
package main
import (
"fmt"
"github.com/dannoane/priority-queue"
)
func main() {
pq := priorityqueue.NewPriorityQueue()
pq.Push(&priorityqueue.Element{Value: 1, Priority: 200})
pq.Push(&priorityqueue.Element{Value: 2, Priority: 100})
pq.Push(&priorityqueue.Element{Value: 3, Priority: 300})
for !pq.IsEmpty() {
fmt.Println(pq.Pop().Value)
}
}