set

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 4 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 values methods

func New

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

New create a set with optional values

func (Set[T]) Add

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

Add value to set

func (Set[T]) AddMultiple

func (s Set[T]) AddMultiple(values ...T) Set[T]

func (Set[T]) Clear

func (s Set[T]) Clear()

Clear empties all itens

func (Set[T]) Diff

func (s Set[T]) Diff(another Set[T]) Set[T]

Diff results a Set with values that are not common to two sets

func (Set[T]) Equals

func (s Set[T]) Equals(another Set[T]) bool

Equals returns true if the set has exactly the same values of the another set

func (Set[T]) Filter

func (s Set[T]) Filter(filter func(T) bool) iter.Seq[T]

Filter returns an iterable with the values that satisfies the filter condition

func (Set[T]) Has

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

Has returns true if the value is in the set

func (Set[T]) HasAll

func (s Set[T]) HasAll(values ...T) bool

HasAll returns true if all the values are in the set

func (Set[T]) Intersection

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

Intersection results a Set with values common to the two sets

func (Set[T]) Iter

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

Iter returns a iterable of the values in the set Due map characteristics, the order is not garanteeded

func (Set[T]) MarshalJSON

func (s Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON produces a list serialization of the itens. The order of the itens is indetermined, so don't do comparisons between two JSONS

func (Set[T]) Remove

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

Remove value from set

func (Set[T]) Scan

func (s Set[T]) Scan(value any) error

Scan will receive data as string or []byte, marshaled as JSON (e.g. '["a","b","c"]')

func (Set[T]) ToArray

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

ToArray returns an unsorted array with the values of the set

func (Set[T]) Union

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

Union two sets to create a new set with all values

func (Set[T]) UnmarshalJSON

func (s Set[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON fills the set with data from JSON

func (Set[T]) UpdateFrom

func (s Set[T]) UpdateFrom(another Set[T]) Set[T]

UpdateFrom adds the values from another set to current

func (Set[T]) Value

func (s Set[T]) Value() (driver.Value, error)

Value will produce []byte JSON from this set

Jump to

Keyboard shortcuts

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