mirror of
https://github.com/hanzoai/oxy.git
synced 2026-09-30 23:42:31 +00:00
570 B
570 B
Priority Queue
Provides a Priority Queue implementation as described here
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