set

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 2 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 cmp.Ordered] struct {
	// contains filtered or unexported fields
}

Set is a simple implementation of a set using a map.

func NewSet

func NewSet[T cmp.Ordered]() *Set[T]

NewSet creates and returns a new set.

func (*Set[T]) Add

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

Add inserts an element into the set.

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear removes all elements from the set.

func (*Set[T]) Contains

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

Contains checks if an element exists in the set.

func (*Set[T]) Diff

func (s *Set[T]) Diff(sets ...*Set[T]) *Set[T]

Diff returns a new set containing elements that are in the current set but not in the provided sets.

func (*Set[T]) Remove

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

Remove deletes an element from the set.

func (*Set[T]) Size

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

Size returns the number of elements in the set.

func (*Set[T]) Update

func (s *Set[T]) Update(sets ...*Set[T])

Update adds all elements from the given sets into the current set.

func (*Set[T]) Values

func (s *Set[T]) Values() []T

Values returns all elements in the set as a slice.

func (*Set[T]) ValuesSorted

func (s *Set[T]) ValuesSorted() []T

ValuesSorted returns all elements in the set as a sorted slice.

Jump to

Keyboard shortcuts

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