set

package
v0.0.0-...-c768733 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Unlicense Imports: 1 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 is a generic set implementation using a map

func New

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

New creates a new empty set

func NewFromValues

func NewFromValues[T comparable](vs ...T) Set[T]

NewFromValues creates a new set from the given values

func (Set[T]) Add

func (s Set[T]) Add(v T) bool

Add returns true when the value is added; otherwise, false when it already exists in the set

func (Set[T]) Clear

func (s Set[T]) Clear()

Clear removes all values from the set

func (Set[T]) Delete

func (s Set[T]) Delete(v T) bool

Delete removes the value from the set if it exists. Returns true if the value was deleted; otherwise, false

func (Set[T]) Has

func (s Set[T]) Has(v T) bool

Has checks if the value exists in the set Returns true if the value exists; otherwise, false

func (Set[T]) Iter

func (s Set[T]) Iter() iter.Seq[T]

Iter returns an iterator over the set values

func (Set[T]) Size

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

Size returns the number of value in the set

func (Set[T]) Values

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

Values returns a slice of all values in the set

Jump to

Keyboard shortcuts

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