This is a priority unsorted queue written in Go (Golang).
- Unsorted list
- Support for custom priority
- Support for custom data type
$ go get github.com/basemax/PriorityUnsortedQueueGo
package main
import "fmt"
func main() {
// Create a new queue
queue := NewPriorityQueue(5)
// Enqueue some items
queue.Enqueue("A", 1)
queue.Enqueue("B", 2)
queue.Enqueue("C", 3)
queue.Enqueue("D", 4)
queue.Enqueue("E", 5)
fmt.Println(queue.ToString())
// Dequeue and print
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
queue.Enqueue("A", 10)
queue.Enqueue("B", 20)
queue.Enqueue("C", 3)
fmt.Println(queue.ToString())
}
© Copyright 2022, Max Base