Retired in favour of github.com/deckarep/golang-set/v2
import "github.com/bruceesmith/set"Package set is based on public code from John Arundel, goroutine safety added. It defines goroutine-safe methods for manipulating a generic set data structure via the standard operations Add, Contains, Intersection, Members, String and Union
- type Set
- func New[E comparable](vals ...E) *Set[E]
- func (s *Set[E]) Add(vals ...E)
- func (s *Set[E]) Clear()
- func (s *Set[E]) Contains(v E) bool
- func (s *Set[E]) Delete(vals ...E)
- func (s *Set[E]) Difference(s2 *Set[E]) *Set[E]
- func (s *Set[E]) Disjoint(s2 *Set[E]) bool
- func (s *Set[E]) Empty() bool
- func (s *Set[E]) Intersection(s2 *Set[E]) *Set[E]
- func (s *Set[E]) Members() []E
- func (s *Set[E]) Size() int
- func (s *Set[E]) String() string
- func (s *Set[E]) Union(s2 *Set[E]) *Set[E]
Set is a generics implementation of the set data type
type Set[E comparable] struct {
// contains filtered or unexported fields
}func New[E comparable](vals ...E) *Set[E]New creates a new Set
func (s *Set[E]) Add(vals ...E)Add puts a new value into a Set
func (s *Set[E]) Clear()Clear removes all values from a Set
func (s *Set[E]) Contains(v E) boolContains checks if a value is in the Set
func (s *Set[E]) Delete(vals ...E)Delete remove values(s) from a Set
func (s *Set[E]) Difference(s2 *Set[E]) *Set[E]Difference returns the set of values that are in s (set A) but not in s2 (set B) ... i.e. A - B
func (s *Set[E]) Disjoint(s2 *Set[E]) boolDisjoint returns true if the intersection of s with another set s2 is empty
func (s *Set[E]) Empty() boolEmpty returns true if the Set is empty
func (s *Set[E]) Intersection(s2 *Set[E]) *Set[E]Intersection returns the logical intersection of 2 Sets
func (s *Set[E]) Members() []EMembers returns a slice of the values in a Set
func (s *Set[E]) Size() intSize returns the number of values in a Set
func (s *Set[E]) String() stringString returns a string representation of the Set members
func (s *Set[E]) Union(s2 *Set[E]) *Set[E]Union returns the logical union of 2 Sets
Generated by gomarkdoc