collection

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: BSD-2-Clause Imports: 7 Imported by: 6

README

Collection

This repo contains collection helpers.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFoundError = stderrors.New("not found")

Functions

func ChannelFnCount added in v1.1.0

func ChannelFnCount[T interface{}](
	ctx context.Context,
	fn func(ctx context.Context, ch chan<- T) error,
) (int, error)

func ChannelFnList

func ChannelFnList[T interface{}](
	ctx context.Context,
	fn func(ctx context.Context, ch chan<- T) error,
) ([]T, error)

func ChannelFnMap

func ChannelFnMap[T interface{}](
	ctx context.Context,
	getFn func(ctx context.Context, ch chan<- T) error,
	mapFn func(ctx context.Context, t T) error,
) error

func Compare added in v1.6.0

func Compare[T ~string](a, b T) int

func Contains

func Contains[T comparable](list []T, value T) bool

func ContainsAll added in v1.2.0

func ContainsAll[T comparable](a []T, b []T) bool

ContainsAll check if all elements of A is in B and all elements of B is in A

func Copy added in v1.3.1

func Copy[T any](values []T) []T

func Equal added in v1.2.0

func Equal[T comparable](a []T, b []T) bool

func Exclude

func Exclude[T comparable](list []T, excludes ...T) []T

func Filter

func Filter[T any](list []T, match func(value T) bool) []T

func Find

func Find[T any](list []T, match func(value T) bool) (*T, error)

func Join added in v1.7.0

func Join[T any](a []T, b []T) []T

Join allow to join two arrays into one new array

func Map added in v1.5.0

func Map[T any](list []T, fn func(value T) error) error

func Ptr

func Ptr[T any](value T) *T

func Reverse

func Reverse[T any](values []T) []T

func StreamList added in v1.8.0

func StreamList[T any](ctx context.Context, list []T, ch chan<- T) error

StreamList streams the given list into the given channel

func UnPtr

func UnPtr[T any](ptr *T) T

func Unique

func Unique[T comparable](list []T) []T

Types

type HasEqual added in v1.3.1

type HasEqual[V any] interface {
	Equal(value V) bool
}

type HasHashCode added in v1.3.1

type HasHashCode interface {
	HashCode() string
}

type Set added in v1.3.0

type Set[T comparable] interface {
	Add(element T)
	Remove(element T)
	Contains(element T) bool
	Slice() []T
	Length() int
}

func NewSet added in v1.3.0

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

type SetEqual added in v1.3.1

type SetEqual[T HasEqual[T]] interface {
	Add(element T)
	Remove(element T)
	Contains(element T) bool
	Slice() []T
	Length() int
}

func NewSetEqual added in v1.3.1

func NewSetEqual[T HasEqual[T]]() SetEqual[T]

type SetHashCode added in v1.3.1

type SetHashCode[T HasHashCode] interface {
	Add(element T)
	Remove(element T)
	Contains(element T) bool
	Slice() []T
	Length() int
}

func NewSetHashCode added in v1.3.1

func NewSetHashCode[T HasHashCode]() SetHashCode[T]

Jump to

Keyboard shortcuts

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