set

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Difference

func Difference[K ordered, V any](a, b *Set[K, V]) []V

Types

type Set

type Set[K ordered, V any] struct {
	// contains filtered or unexported fields
}

Set is a set of values of type V, indexed by keys of type K. We require an orderable type, so that we can provide a deterministic output. There are other ways to return a deterministic output (i.e., maintain the insert order), but this is the simplest.

func NewSet

func NewSet[T ordered](vals ...T) *Set[T, T]

func NewSetWithCustomKey

func NewSetWithCustomKey[K ordered, V any](getKey func(V) K, vals ...V) *Set[K, V]

func (*Set[K, V]) Add

func (s *Set[K, V]) Add(vals ...V)

func (*Set[K, V]) Has

func (s *Set[K, V]) Has(val V) bool

func (*Set[K, V]) Values

func (s *Set[K, V]) Values() []V

Jump to

Keyboard shortcuts

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