set

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package set contains a basic generic Set type.

Index

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]) Add

func (set Set[E]) Add(vals ...E) Set[E]

Add adds values to the set.

func (Set[E]) All

func (set Set[E]) All() []E

All returns all values in the set.

func (Set[E]) Contains added in v0.1.9

func (set Set[E]) Contains(other Set[E]) bool

Contains returns true if one set contains all elements of the other.

func (Set[E]) Del

func (set Set[E]) Del(vals ...E) Set[E]

Del removes values from the set.

func (Set[E]) Equal added in v0.1.9

func (set Set[E]) Equal(other Set[E]) bool

Equal compares two sets for exact equality.

func (Set[E]) Has

func (set Set[E]) Has(val E) bool

Has returns true if the set contains the given value.

func (Set[E]) Intersect

func (set Set[E]) Intersect(other Set[E]) Set[E]

Intersect computes the intersection of two sets, producing a set that only contains the values present in both sets.

func (Set[E]) Len

func (set Set[E]) Len() int

Len returns the size of the set.

func (Set[E]) MarshalJSON added in v0.1.4

func (set Set[E]) MarshalJSON() ([]byte, error)

MarshalJSON marshals a set as a JSON array.

func (Set[E]) MarshalYAML added in v0.1.10

func (set Set[E]) MarshalYAML() (any, error)

MarshalYAML marshals a set as a YAML array.

func (Set[E]) Union

func (set Set[E]) Union(other Set[E]) Set[E]

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

func (set *Set[E]) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a set from a JSON array.

func (*Set[E]) UnmarshalYAML added in v0.1.10

func (set *Set[E]) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML unmarshals a set from a YAML array.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL