Skip to content

rocketbitz/set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

set CircleCI

a simple set for gophers

installation

as with all other go packages, you know what to do:

go get github.com/rocketbitz/set

usage

go should probably have its own, but it doesn't, so here you are:

package main

import (
	"fmt"

	"github.com/rocketbitz/set"
)

func main() {
    s := set.New()

    s.Add("gopher_0")
    s.Add("gopher_1")

    s.Contains("gopher_0")  // true
    s.Contains("gopher_2")  // false

    s.Slice()  // []interface{}{"gopher_0", "gopher_2"}

    s.Remove("gopher_0")

    s.Len()  // 1

    s.At(0)  // "gopher_2"
    s.Index("gopher_2")  // 0
}

if you want to handle the thread-safety yourself, then by all means:

s := NewUnsafe()

contribute

pr's are welcome. if they're awesome, they'll get reviewed and merged. if they're not, they'll get reviewed and closed, hopefully with a kind comment as to the reason.

license

MIT ...move along, move along.