Skip to content

abishekk92/goset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goset

Build Status GoDoc experimental

Set implementation for golang

To install goset

    go get github.com/abishekk92/goset

To Create a new set

    import (
        "github.com/abishekk92/goset"
        )

    func main() {
        newSet := goset.NewSet() //Creates a new set
        newSet.Add("a", "b") //Adds a new element to the set
        newSet.Del("b") //Removes an element from the set
        newSet.IsMember("a") //Checks if 'a' is a member of the set
    }

To Union two sets

    import (
        "github.com/abishekk92/goset"
        )

    func main() {
        A := goset.NewSet()
        B := goset.NewSet()
        A.Add("a", "b")
        B.Add("a")
        uninonSet := A.Union(B)
    }

To Intersect two sets

    import (
        "github.com/abishekk92/goset"
        )

    func main() {
        A := goset.NewSet()
        B := goset.NewSet()
        A.Add("a", "b")
        B.Add("a")
        intersectionSet := A.Intersect(B)
    }

To get an array of elements

    import (
        "github.com/abishekk92/goset"
        )

    func main() {
        A := goset.NewSet()
        A.Add("a", "b")
        items := A.ToArray()
    }

About

Set implementation for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages