github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/structure/sets/sets.go (about) 1 // Package sets provides an abstract Set interface. 2 // 3 // In computer science, a set is an abstract data type that can store certain values and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests a value for membership in a set. 4 // 5 // Reference: https://en.wikipedia.org/wiki/Set_%28abstract_data_type%29 6 package sets 7 8 import "github.com/songzhibin97/go-baseutils/structure/containers" 9 10 // Set interface that all sets implement 11 type Set[E any] interface { 12 Add(elements ...E) 13 Remove(elements ...E) 14 Contains(elements ...E) bool 15 // Intersection(another *Set) *Set 16 // Union(another *Set) *Set 17 // Difference(another *Set) *Set 18 19 containers.Container[E] 20 // Empty() bool 21 // Size() int 22 // Clear() 23 // Values() []E{} 24 // String() string 25 }