This is an extended version of the Go's builtin container package with support of generics and new 1.23 iterators feature.
There are already similar ones, for example, gods, but I don't like it for being too Java-ish.
go get github.com/kodeyeen/container
package main
import (
"cmp"
"fmt"
"github.com/kodeyeen/container/pqueue"
)
func main() {
pq := pqueue.New(cmp.Compare[int])
pq.Init(44, 22, 11, 33)
pq.Enqueue(-55)
min, ok := pq.Peek()
if ok {
fmt.Printf("Minimum value is %d\n", min)
}
for elem := range pq.All() {
fmt.Println(elem)
}
}