10
GitHub - rutaka-n/genericset: simple map-based implementation of generic set in...
source link: https://github.com/rutaka-n/genericset
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Generic Set
genericset
provides a simple map-based implementation of generic set.
It uses sync.RWMutex
to keep consistency of data.
Installation
go get github.com/rutaka-n/genericset
Usage
import (
gs "github.com/rutaka-n/genericset"
)
func main() {
s1 := gs.New[int]()
s2 := gs.New[int]()
s1.Add(1,2,3)
s2.Add(3,4,5)
s1.Intersection(&s2) // [3]
s1.Union(&s2) // [1,2,3,4,5]
s1.IsEmpty() // false
s1.Size() // 3
s1.IsSubset(&s2) // false
// etc
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK