sets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 2 Imported by: 8

Documentation

Overview

Package sets provides generic sets.

Index

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

func (s Set[T]) Add(t ...T) Set[T]

Add inserts the given elements to s and returns s.

func (Set[T]) AddSet

func (s Set[T]) AddSet(t Set[T]) Set[T]

AddSet inserts the elements of t to s and returns s.

func (Set[T]) Has

func (s Set[T]) Has(t T) bool

Has returns whether t is a member of s.

func (Set[T]) Intersect

func (s Set[T]) Intersect(t Set[T]) Set[T]

Intersect returns a new set holding the elements that are common to s and t.

func (Set[T]) MarshalJSON added in v0.1.13

func (s Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Set[T]) Remove

func (s Set[T]) Remove(t ...T) Set[T]

Remove deletes the given elements from s and returns s.

func (Set[T]) RemoveSet

func (s Set[T]) RemoveSet(t Set[T]) Set[T]

RemoveSet deletes the elements of t from s and returns s.

func (*Set[T]) UnmarshalJSON added in v0.1.13

func (s *Set[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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