set

package
v0.0.0-...-271081e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StopIteration = errors.New("stop iteration")
	RemoveItem    = errors.New("remove item")
)

Functions

func IterUnion

func IterUnion[T comparable](sets []Set[T], f func(item T) bool)

IterUnion iterates over the values in the union of the given sets. For small numbers of sets, it can avoid allocating an actual union set. Iteration continues while the passed in func returns true.

Types

type Set

type Set[T any] interface {
	Len() int
	Add(T)
	AddAll(itemArray []T)
	AddSet(other Set[T])
	Discard(T)
	Clear()
	Contains(T) bool
	Iter(func(item T) error)
	Copy() Set[T]
	Equals(Set[T]) bool
	ContainsAll(Set[T]) bool
	Slice() []T
	fmt.Stringer
}

type Typed

type Typed[T comparable] map[T]v

func Empty

func Empty[T comparable]() Typed[T]

Empty returns a read-only set with no members. Calls to Add etc. panic.

func From

func From[T comparable](members ...T) Typed[T]

func FromArray

func FromArray[T comparable](membersArray []T) Typed[T]

func New

func New[T comparable]() Typed[T]

func NewSize

func NewSize[T comparable](size int) Typed[T]

func (Typed[T]) Add

func (set Typed[T]) Add(item T)

func (Typed[T]) AddAll

func (set Typed[T]) AddAll(itemArray []T)

func (Typed[T]) AddSet

func (set Typed[T]) AddSet(other Set[T])

AddSet adds the contents of set "other" into the set.

func (Typed[T]) Clear

func (set Typed[T]) Clear()

func (Typed[T]) Contains

func (set Typed[T]) Contains(item T) bool

func (Typed[T]) ContainsAll

func (set Typed[T]) ContainsAll(other Set[T]) bool

func (Typed[T]) Copy

func (set Typed[T]) Copy() Set[T]

func (Typed[T]) Discard

func (set Typed[T]) Discard(item T)

func (Typed[T]) Equals

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

func (Typed[T]) Iter

func (set Typed[T]) Iter(visitor func(item T) error)

func (Typed[T]) Len

func (set Typed[T]) Len() int

func (Typed[T]) Slice

func (set Typed[T]) Slice() (s []T)

func (Typed[T]) String

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

Jump to

Keyboard shortcuts

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