set

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 1 Imported by: 8

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 container that store unique elements in no particular order. Sets are an alias for map[T]struct{} where T is a comparable type.

func NewSet

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

NewSet creates a new Set from a list of values.

func (Set[T]) Add

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

Add adds a value to the set.

func (Set[T]) AddSet added in v0.0.3

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

func (Set[T]) Contains

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

Contains returns true if the set contains the value.

func (Set[T]) ContainsAll

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

ContainsAll returns true if the set contains all the values.

func (Set[T]) MarshalJSON added in v0.0.2

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

func (Set[T]) PtrSlice added in v0.0.4

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

func (Set[T]) Remove

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

Remove removes a value from the set. Returns true if the set contained the value.

func (Set[T]) RemoveAll

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

RemoveAll removes all values from the set.

func (Set[T]) Slice

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

Slice returns a slice of the values in the set.

func (*Set[T]) UnmarshalJSON added in v0.0.2

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

Jump to

Keyboard shortcuts

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