A simple and smallest binary heap priority queue in golang
A simple and smallest binary heap priority queue in golang.
go get -u github.com/anjulapaulus/tinyqueue
The current implementation is inspired on the javascript library tinyqueue by Vladimir Agafonkin.
````
package main
import queue “github.com/anjulapaulus/tinyqueue”
type Val int64
func (a Val) Compare (b queue.Item) bool{
return a <= b.(Val)
}
func main(){
q:= queue.Queue{} //Initialize Queue
q.Push(Val(2)) //Insert Items to queue
q.Push(Val(5))
q.Push(Val(10))
array := q.All() //returns array of elemeents in queue
q.Peek() //returns the top item without removal
q.Len() //length of queue
q.Pop() //removes the top item and displays
}