sets

package
v0.0.0-...-ecabb92 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Map

func Map[T comparable, ResultT any](s *Set[T], f func(elem T) (ResultT, error)) ([]ResultT, error)

Types

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func Diff

func Diff[T comparable](outer, inner *Set[T]) *Set[T]

diff two sets, return elements of outer not in inner

func FromSlice

func FromSlice[T comparable](sl []T) *Set[T]

func Intersect

func Intersect[T comparable](s1, s2 *Set[T]) *Set[T]

return a new set containing only elements that are present in both sets

func New

func New[T comparable](sl ...T) *Set[T]

func NewSet

func NewSet[T comparable]() *Set[T]

func Union

func Union[T comparable](s1, s2 *Set[T]) *Set[T]

return a new set containing elements from both sets

func (*Set[T]) Add

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

func (*Set[T]) AddSet

func (s *Set[T]) AddSet(set2 *Set[T]) *Set[T]

func (*Set[T]) AsSlice

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

func (*Set[T]) Clone

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

func (*Set[T]) Contains

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

func (*Set[T]) GetAny

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

get any object from the set. return empty value if set is empty.

func (*Set[T]) Iterate

func (s *Set[T]) Iterate(f func(elem T) error) error

func (*Set[T]) Len

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

func (*Set[T]) Remove

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

Jump to

Keyboard shortcuts

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