set

package module
v0.0.0-...-9cb4c9f Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: GPL-3.0 Imports: 0 Imported by: 1

Documentation

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 generic set implementation

func New

func New[T comparable](items ...T) Set[T]

New creates a new set

func (Set[T]) Add

func (s Set[T]) Add(item T)

Add adds an item to the set

func (Set[T]) Contains

func (s Set[T]) Contains(item T) bool

Contains checks if an item is in the set

func (Set[T]) Difference

func (s Set[T]) Difference(other Set[T]) Set[T]

Difference returns a new set containing all items in the first set that are not in the second set

func (Set[T]) Intersection

func (s Set[T]) Intersection(other Set[T]) Set[T]

Intersection returns a new set containing all items common to both sets

func (Set[T]) Items

func (s Set[T]) Items() []T

Items returns a slice of all items in the set

func (Set[T]) Len

func (s Set[T]) Len() int

Len returns the number of items in the set

func (Set[T]) Remove

func (s Set[T]) Remove(item T)

Remove removes an item from the set

func (Set[T]) SymmetricDifference

func (s Set[T]) SymmetricDifference(other Set[T]) Set[T]

SymmetricDifference returns a new set containing all items in either set, but not both

func (Set[T]) Union

func (s Set[T]) Union(other Set[T]) Set[T]

Union returns a new set containing all items from both sets

Jump to

Keyboard shortcuts

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