Documentation
¶
Index ¶
- type Set
- func (s *Set[T]) Add(items ...T)
- func (s *Set[T]) Append(set Set[T])
- func (s *Set[T]) Clone() Set[T]
- func (s *Set[T]) Contains(item T) bool
- func (s *Set[T]) ContainsAllAnd(items ...T) bool
- func (s *Set[T]) ContainsAllOr(items ...T) bool
- func (s *Set[T]) Difference(set Set[T]) Set[T]
- func (s *Set[T]) Intersection(set Set[T]) Set[T]
- func (s *Set[T]) Len() uint32
- func (s *Set[T]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) Remove(item T)
- func (s *Set[T]) Replace(set Set[T])
- func (s *Set[T]) Reset()
- func (s *Set[T]) Scan(value interface{}) error
- func (s *Set[T]) ToSlice() []T
- func (s *Set[T]) Union(set Set[T]) Set[T]
- func (s *Set[T]) UnionByStrategy(set Set[T], strategy Strategy) Set[T]
- func (s *Set[T]) UnmarshalJSON(data []byte) error
- func (s *Set[T]) Value() (driver.Value, error)
- type Strategy
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 generic collection type that stores unique elements of type T.
It can be used as a replacement for map[T]struct{} with a cleaner API. The zero value (nil) is ready to use and represents an empty set.
The type implements:
- Basic operations: Add, Remove, Contains, Len, ToSlice
- Set operations: Append (union), Clone
- JSON marshaling/unmarshaling
- SQL driver.Valuer and sql.Scanner interfaces
All methods are safe to call on nil receiver and will not panic.
func NewSet ¶
func NewSet[T comparable](items ...T) Set[T]
func (*Set[T]) ContainsAllAnd ¶ added in v0.0.16
func (*Set[T]) ContainsAllOr ¶ added in v0.0.16
func (*Set[T]) Difference ¶ added in v0.0.17
func (*Set[T]) Intersection ¶ added in v0.0.17
func (*Set[T]) MarshalJSON ¶
func (*Set[T]) UnionByStrategy ¶ added in v0.0.18
func (*Set[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.