Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 672 Bytes

README.md

File metadata and controls

39 lines (28 loc) · 672 Bytes

container

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.

Installation

go get github.com/kodeyeen/container

Quickstart

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)
	}
}