a simple set for gophers
as with all other go packages, you know what to do:
go get github.com/rocketbitz/set
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()
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.
MIT ...move along, move along.