Skip to content
/ go-util Public

contains generic collection interfaces and implementations, and other utilities for working with collections.

License

Notifications You must be signed in to change notification settings

yzrzr/go-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-util

This is a [Go] language util,contains generic collection interfaces and implementations, and other utilities for working with collections. [quick start][].

Installation

With [Go module][] support (Go 1.17+)

Interface

Example

list:

package main

import (
	"fmt"

	"github.com/yzrzr/go-util/collect"
)

func main() {
	list := collect.NewList[int](collect.DefaultListConfig)
	list.Add(1)
	list.Add(2)
	list.Add(3)
	fmt.Println(list.ToArray()) // [1, 2, 3]
	list.Sort(collect.SortLessOrdered[int](false))
	fmt.Println(list.ToArray()) // [3, 2, 1]
}

set:

package main

import (
	"fmt"

	"github.com/yzrzr/go-util/collect"
)

func main() {
	set := collect.NewSet[int]()
	set.Add(10)
	set.Add(10)
	set.Add(20)
	fmt.Println(set.ToArray()) // [10, 20]
}

Learn more

About

contains generic collection interfaces and implementations, and other utilities for working with collections.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages