Documentation ¶
Overview ¶
Package set contains a basic generic Set type.
Index ¶
- type Set
- func (set Set[E]) Add(vals ...E) Set[E]
- func (set Set[E]) All() []E
- func (set Set[E]) Contains(other Set[E]) bool
- func (set Set[E]) Del(vals ...E) Set[E]
- func (set Set[E]) Equal(other Set[E]) bool
- func (set Set[E]) Has(val E) bool
- func (set Set[E]) Intersect(other Set[E]) Set[E]
- func (set Set[E]) Len() int
- func (set Set[E]) MarshalJSON() ([]byte, error)
- func (set Set[E]) MarshalYAML() (any, error)
- func (set Set[E]) Union(other Set[E]) Set[E]
- func (set *Set[E]) UnmarshalJSON(b []byte) error
- func (set *Set[E]) UnmarshalYAML(n *yaml.Node) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[E comparable] map[E]struct{}
A Set is an unordered collection of values with the ability to test for inclusion and exclusion.
func NewSet ¶
func NewSet[E comparable](vals ...E) Set[E]
NewSet creates a new set from a collection of values.
func (Set[E]) Contains ¶ added in v0.1.9
Contains returns true if one set contains all elements of the other.
func (Set[E]) Intersect ¶
Intersect computes the intersection of two sets, producing a set that only contains the values present in both sets.
func (Set[E]) MarshalJSON ¶ added in v0.1.4
MarshalJSON marshals a set as a JSON array.
func (Set[E]) MarshalYAML ¶ added in v0.1.10
MarshalYAML marshals a set as a YAML array.
func (Set[E]) Union ¶
Union computes the union of two sets, producing a set that contains the values present in either set.
func (*Set[E]) UnmarshalJSON ¶ added in v0.1.4
UnmarshalJSON unmarshals a set from a JSON array.
func (*Set[E]) UnmarshalYAML ¶ added in v0.1.10
UnmarshalYAML unmarshals a set from a YAML array.