collections

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 2 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyIterator

func CopyIterator[T any](it Iterator[*T]) (*sliceIterator[*T], error)

func CopyMap

func CopyMap[K comparable, V any](to map[K]V, from map[K]V)

func Difference

func Difference[V comparable](a, b []V) []V

func Intersection

func Intersection[V comparable](a, b []V) []V

func InverseMap

func InverseMap[K comparable, V comparable](in map[K]V) map[V]K

func Keys

func Keys[K comparable, V any](m map[K]V) []K

func NewEmptyIterator

func NewEmptyIterator[K any]() *emptyIterator[K]

func NewPermutatedIterator

func NewPermutatedIterator[T any](it Iterator[*T]) (*sliceIterator[*T], error)

func NewSliceIterator

func NewSliceIterator[T any](items []T) *sliceIterator[T]

func ReadAll

func ReadAll[T any](it Iterator[*T]) ([]T, error)

func ReadFirst

func ReadFirst[T any](it Iterator[*T], limit int) ([]T, error)

func Remove

func Remove[T comparable](items []T, toRemove T) ([]T, bool)

func Repeat

func Repeat[T any](item T, times int) []T

func RepeatValue

func RepeatValue[K comparable, V any](keys []K, val V) map[K]V

func SubMap

func SubMap[K comparable, V any](m map[K]V, ks ...K) (map[K]V, []K)

func Values

func Values[K comparable, V any](m map[K]V) []V

Types

type Iterator

type Iterator[V any] interface {

	// Close releases resources occupied by the iterator
	Close()
	// contains filtered or unexported methods
}

func Map

func Map[A any, B any](iterator Iterator[A], transformer func(A) (B, error)) Iterator[B]

type Set

type Set[V comparable] interface {
	Add(...V)
	Remove(...V)
	Minus(Set[V]) Set[V]
	Contains(V) bool
	ToSlice() []V
	Empty() bool
	Length() int
}

func NewSet

func NewSet[V comparable](items ...V) Set[V]

Jump to

Keyboard shortcuts

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