set

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 3 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[A any] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[A comparable](elems []A) *Set[A]

func NewSetBy

func NewSetBy[A any, K comparable](projection func(A) K, elems []A) *Set[A]

func (*Set[A]) Add

func (s *Set[A]) Add(a A) bool

func (*Set[A]) Contains

func (s *Set[A]) Contains(a A) bool

func (*Set[A]) Delete

func (s *Set[A]) Delete(a A) bool

func (*Set[A]) Difference

func (s *Set[A]) Difference(other *Set[A]) int

Difference removes any items from `s` which are in `other`

func (*Set[A]) Intersect

func (s *Set[A]) Intersect(other *Set[A]) int

Intersect removes any items from `s` which are NOT in `other`

func (*Set[A]) Len

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

func (*Set[A]) ToSlice

func (s *Set[A]) ToSlice() []A

func (*Set[A]) Union

func (s *Set[A]) Union(other *Set[A]) int

type Wrapper

type Wrapper[A any, K comparable] struct {
	Elems      map[K]A
	Projection func(A) K
}

func NewWrapper

func NewWrapper[A comparable](elems []A) *Wrapper[A, A]

func NewWrapperBy

func NewWrapperBy[A any, K comparable](projection func(A) K, elems []A) *Wrapper[A, K]

func (*Wrapper[A, K]) Add

func (s *Wrapper[A, K]) Add(a A) bool

func (*Wrapper[A, K]) Contains

func (s *Wrapper[A, K]) Contains(a A) bool

func (*Wrapper[A, K]) Delete

func (s *Wrapper[A, K]) Delete(a A) bool

func (*Wrapper[A, K]) Len

func (s *Wrapper[A, K]) Len() int

func (*Wrapper[A, K]) ToSlice

func (s *Wrapper[A, K]) ToSlice() []A

Jump to

Keyboard shortcuts

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