Documentation ¶
Overview ¶
Package sets provides generic sets.
Index ¶
- type Set
- func (s Set[T]) Add(t ...T) Set[T]
- func (s Set[T]) AddSet(t Set[T]) Set[T]
- func (s Set[T]) Has(t T) bool
- func (s Set[T]) Intersect(t Set[T]) Set[T]
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) Remove(t ...T) Set[T]
- func (s Set[T]) RemoveSet(t Set[T]) Set[T]
- func (s *Set[T]) UnmarshalJSON(b []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 convenience wrapper around map[T]struct{}.
func AddKeys ¶ added in v0.5.0
func AddKeys[K comparable, V any](s Set[K], m map[K]V) Set[K]
AddKeys adds the keys of a map to a set.
func AddValues ¶ added in v0.5.0
func AddValues[K comparable, V comparable](s Set[V], m map[K]V) Set[V]
AddValues adds the values of a map to a set.
func FromKeys ¶ added in v0.5.0
func FromKeys[K comparable, V any](m map[K]V) Set[K]
FromKeys returns a new set containing the keys of the given map.
func FromValues ¶ added in v0.5.0
func FromValues[K comparable, V comparable](m map[K]V) Set[V]
FromValues returns a new set containing the values of the given map.
func Of ¶ added in v0.5.0
func Of[T comparable](t ...T) Set[T]
Of returns a new set containing the given elements.
func (Set[T]) Intersect ¶
Intersect returns a new set holding the elements that are common to s and t.
func (Set[T]) MarshalJSON ¶ added in v0.1.13
MarshalJSON implements the json.Marshaler interface.
func (*Set[T]) UnmarshalJSON ¶ added in v0.1.13
UnmarshalJSON implements the json.Unmarshaler interface.
Click to show internal directories.
Click to hide internal directories.