Documentation
¶
Overview ¶
Package sets contains functions related to a generic Set implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set represents a finite set (in the sense of Discrete mathematics) of comparable elements. It supports standard set operations such as union and set difference.
func Difference ¶
func Difference[T comparable](A, B Set[T]) Set[T]
Difference returns the set difference of sets A and B. The result contains all elements of A which cannot be found in B.
func Intersect ¶
func Intersect[T comparable](A, B Set[T]) Set[T]
Intersect returns the intersection of sets A and B. The result contains all elements of A which are also in B.
func New ¶
func New[T comparable](elems ...T) Set[T]
New constructs a new set with the provided elements. Duplicate elements are collapsed.
func SymmetricDiff ¶
func SymmetricDiff[T comparable](A, B Set[T]) Set[T]
SymmetricDiff returns the symmetric difference of sets A and B. The result contains all elements of A and B, except those elements which are found in both A and B.
func Union ¶
func Union[T comparable](A, B Set[T]) Set[T]
Union returns the union of sets A and B. The result contains all elements of A and all elements of B.
func (Set[T]) Add ¶
func (s Set[T]) Add(elem T)
Add adds the provided element to this set, modifying it if it does not already exist.
func (Set[T]) Contains ¶
Contains returns true if and only if this set contains the provided element.
func (Set[T]) ContainsSet ¶
ContainsSet returns true if and only if this set contains the other set.