set

package module
v0.0.0-...-7ea7fd6 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package set set.go

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{}

func NewSet

func NewSet[T comparable](values ...T) Set[T]

NewSet creates a new set and initializes it with the provided values.

func (Set[T]) Add

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

Add a new element to the set

func (Set[T]) Clear

func (s Set[T]) Clear()

Clear removes all elements from the set.

func (Set[T]) Clone

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

Clone creates a copy of the set.

func (Set[T]) Contains

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

Contains checks if an element is in the set

func (Set[T]) Difference

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

Difference creates a new set that is the difference of two sets.

func (Set[T]) Intersection

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

Intersection creates a new set that is the intersection of two sets.

func (Set[T]) IsSubset

func (s Set[T]) IsSubset(other Set[T]) bool

IsSubset checks if one set is a subset of another.

func (Set[T]) Map

func (s Set[T]) Map(values []T)

Map adds every value from a slice to the set.

func (Set[T]) Remove

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

Remove an element from the set

func (Set[T]) Size

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

Size gets the size of the set

func (Set[T]) Union

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

Union creates a new set that is the union of two sets.

Jump to

Keyboard shortcuts

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