Documentation ¶
Overview ¶
Package set provides a set type with some useful helper functions.
Index ¶
- type Set
- func (s Set[T]) Contains(item T) bool
- func (s Set[T]) Difference(other Set[T]) Set[T]
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Evict(item T) bool
- func (s Set[T]) Insert(items ...T)
- func (s Set[T]) Intersection(other Set[T]) Set[T]
- func (s Set[T]) IsSupersetOf(other Set[T]) bool
- func (s Set[T]) Items() []T
- func (s Set[T]) Size() int
- func (s Set[T]) String() string
- func (s Set[T]) SymmetricDifference(other Set[T]) Set[T]
- func (s Set[T]) Union(other 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 is a unique, unordered collection of elements.
func New ¶ added in v0.7.5
func New[T comparable](sorter func([]T), items ...T) Set[T]
New creates a new set.
func NewStringSet ¶
NewStringSet returns a set of strings.
func NewTimestampSet ¶
NewTimestampSet returns a set of time.Times
func NewUUIDSet ¶
NewUUIDSet returns a set of uuid.UUIDs
func (Set[T]) Difference ¶
Difference returns elements of the set not in the other.
func (Set[T]) Intersection ¶
Intersection returns elements common to both sets.
func (Set[T]) IsSupersetOf ¶
IsSupersetOf checks if the set contains all the elements of the other set.
func (Set[T]) SymmetricDifference ¶
SymmetricDifference returns elements of both sets that are not in the other.
This is a shortcut for calling x.Difference(y) + y.Difference(x).
Click to show internal directories.
Click to hide internal directories.