Documentation
¶
Overview ¶
Package sets provides a set of functions for working with sets
Index ¶
- type Set
- func (s Set[T]) Add(es ...T)
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Complement(t Set[T]) Set[T]
- func (s Set[T]) Contains(v T) bool
- func (s Set[T]) Difference(t Set[T]) Set[T]
- func (s Set[T]) Has(v T) bool
- func (s Set[T]) Intersection(t Set[T]) Set[T]
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) Len() int
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) Remove(es ...T)
- func (s Set[T]) Slice() []T
- func (s Set[T]) String() string
- func (s Set[T]) Union(t Set[T]) Set[T]
- func (s *Set[T]) UnmarshalJSON(bytes []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a set of elements T must be comparable, as map key, val uses empty struct to reduce space
func NewSet ¶
func NewSet[T comparable](es ...T) Set[T]
NewSet creates a new set from a list of elements
func NewSetBySlice ¶
func NewSetBySlice[T comparable, D any](slice []D, fn func(d D) T) Set[T]
func (Set[T]) Add ¶
func (s Set[T]) Add(es ...T)
Add elements to set s if element is already in s this has no effect
func (Set[T]) Complement ¶
Complement returns the complement of two sets
func (Set[T]) Difference ¶
Difference returns the difference of two sets
func (Set[T]) Intersection ¶
Intersection returns the intersection of two sets
Click to show internal directories.
Click to hide internal directories.