set

package
v0.88.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

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 represents a generic set data structure.

func New

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

New creates a new set and initializes it with the provided elements.

func Union added in v0.72.0

func Union[T comparable](sets ...Set[T]) Set[T]

Union merges the given sets into a new set containing all unique elements from the input sets.

func (Set[T]) Add

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

Add inserts the specified elements into the set.

func (Set[T]) Contains

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

Contains checks if the set contains the specified element.

func (Set[T]) Difference added in v0.77.0

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

Difference returns a new set containing the elements in s that are not in other.

func (Set[T]) Len added in v0.73.0

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

func (Set[T]) Remove

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

Remove deletes the specified element from the set.

func (Set[T]) ToSlice

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

ToSlice converts the set to a slice of its elements.

Jump to

Keyboard shortcuts

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