Debian Codegraph @

internal/holsterv4/collections/README.md

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