set

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator[T comparable] struct {
	C <-chan T
	// contains filtered or unexported fields
}

Iterator defines an iterator over a Set, its C channel can be used to range over the Set's elements.

func (*Iterator[T]) Stop

func (i *Iterator[T]) Stop()

Stop stops the Iterator, no further elements will be received on C, C will be closed.

type Set

type Set[T comparable] map[T]struct{}

func New

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

New create new set

func (Set[T]) Add

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

Add to set

func (Set[T]) Cardinality

func (set Set[T]) Cardinality() int

func (Set[T]) CheckAndAdd

func (set Set[T]) CheckAndAdd(i T) bool

CheckAndAdd check if exists and add

func (*Set[T]) Clear

func (set *Set[T]) Clear()

func (Set[T]) Clone

func (set Set[T]) Clone() Set[T]

func (Set[T]) Contains

func (set Set[T]) Contains(i ...T) bool

Contains does value exist in set

func (Set[T]) Difference

func (set Set[T]) Difference(other Set[T]) Set[T]

func (Set[T]) Equals

func (set Set[T]) Equals(other Set[T]) bool

func (Set[T]) HasOverlap

func (set Set[T]) HasOverlap(other Set[T]) bool

func (Set[T]) Intersect

func (set Set[T]) Intersect(other Set[T]) Set[T]

func (Set[T]) IsEmpty

func (set Set[T]) IsEmpty() bool

func (Set[T]) IsSubset

func (set Set[T]) IsSubset(other Set[T]) bool

func (Set[T]) IsSuperset

func (set Set[T]) IsSuperset(other Set[T]) bool

func (Set[T]) Iter

func (set Set[T]) Iter() <-chan T

func (Set[T]) Iterator

func (set Set[T]) Iterator() *Iterator[T]

func (Set[T]) MarshalJSON

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

MarshalJSON creates a JSON array from the set, it marshals all elements

func (Set[T]) Merge

func (set Set[T]) Merge(others ...Set[T])

Merge Sets

func (Set[T]) Remove

func (set Set[T]) Remove(i T)

func (Set[T]) String

func (set Set[T]) String() string

func (Set[T]) SymmetricDifference

func (set Set[T]) SymmetricDifference(other Set[T]) Set[T]

func (Set[T]) ToSlice

func (set Set[T]) ToSlice() []T

func (Set[T]) Union

func (set Set[T]) Union(other ...Set[T]) Set[T]

func (*Set[T]) UnmarshalJSON

func (set *Set[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON recreates a set from a JSON array, it only decodes primitive types. Numbers are decoded as json.Number.

Jump to

Keyboard shortcuts

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