Skip to content
forked from ramalho/strset

A full-featured set type for string elements in Go

License

Notifications You must be signed in to change notification settings

rjfonseca/strset

 
 

Repository files navigation

strset

GoDoc

Full-featured Go Set type for string elements.

func Example() {
	s1 := Make("red", "green", "blue", "yellow")
	s2 := MakeFromText("yellow green white")
	fmt.Println(s1.Intersection(s2))
	// Output: Set{green yellow}
}

Some features of the strset.Set type:

  • Make builds a set from zero or more strings (or []string...).
  • MakeFromText builds a set from a single string with elements separated by whitespace.
  • String method returns elements in ascending order.
  • Methods returning new sets: intersection, union, difference, symmetric difference.
  • Methods updating receiver in-place for each operation above.
  • Pop method to retrieve and delete one unspecified element.
  • Need an immutable set? Just remove updaters.go from the build.
  • 100% test coverage.
  • Not thread-safe.

Happy hacking!

About

A full-featured set type for string elements in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%