Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 662 Bytes

README.md

File metadata and controls

35 lines (26 loc) · 662 Bytes

Go Reference

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
}