Documentation
¶
Overview ¶
Package set implements a Set type for Go.
Index ¶
- type Set
- func (s Set[T]) Add(elem T) bool
- func (s Set[T]) Cardinality() int
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Contains(elem T) bool
- func (s Set[T]) Difference(s2 Set[T]) Set[T]
- func (s Set[T]) Elements() []T
- func (s Set[T]) Equal(s2 Set[T]) bool
- func (s Set[T]) Intersection(s2 Set[T]) Set[T]
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) IsProperSubset(s2 Set[T]) bool
- func (s Set[T]) IsSubset(s2 Set[T]) bool
- func (s Set[T]) Remove(elem T) bool
- func (s Set[T]) String() string
- func (s Set[T]) SymDifference(s2 Set[T]) Set[T]
- func (s Set[T]) Union(s2 Set[T]) Set[T]
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 type.
func (Set[T]) Add ¶
Add adds elem to the Set. Returns true if it was added, false if it already was in the set.
func (Set[T]) Cardinality ¶
Cardinality returns the number of elements in the Set.
func (Set[T]) Difference ¶
Difference returns a new Set which is the set difference of s and s2.
func (Set[T]) Elements ¶
func (s Set[T]) Elements() []T
Elements returns a slice with all elements of the Set.
func (Set[T]) Intersection ¶
Intersection returns a new Set which is the intersection of s and s2.
func (Set[T]) IsProperSubset ¶ added in v0.2.0
IsProperSubset returns true if s is a proper subset of s2.
func (Set[T]) Remove ¶
Remove removes elem from the Set. Returns true if it was in the set, false otherwise.
func (Set[T]) SymDifference ¶ added in v0.2.0
SymDifference returns a new Set which is the symmetric difference of s and s2.
Click to show internal directories.
Click to hide internal directories.