1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
## Priority Queue
Provides a Priority Queue implementation as described [here](https://en.wikipedia.org/wiki/Priority_queue)
```go
queue := collections.NewPriorityQueue()
queue.Push(&collections.PQItem{
Value: "thing3",
Priority: 3,
})
queue.Push(&collections.PQItem{
Value: "thing1",
Priority: 1,
})
queue.Push(&collections.PQItem{
Value: "thing2",
Priority: 2,
})
// Pops item off the queue according to the priority instead of the Push() order
item := queue.Pop()
fmt.Printf("Item: %s", item.Value.(string))
// Output: Item: thing1
```
|