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]) Len() uint32
- func (s *Set[T]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) Remove(item T)
- func (s *Set[T]) Reset()
- func (s *Set[T]) Scan(value interface{}) error
- func (s *Set[T]) ToSlice() []T
- func (s *Set[T]) UnmarshalJSON(data []byte) error
- func (s *Set[T]) Value() (driver.Value, 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 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]) MarshalJSON ¶
func (*Set[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.