stream

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoChunkFunc

type DoChunkFunc[V any] func(from, to int, chunk []V) error

type DoFunc

type DoFunc[V any] func(i int, a V) error

type EqFunc

type EqFunc[V any] func(i int, a V, j int, b V) bool

type ExpandFunc

type ExpandFunc[V any] func(i int, a V) []V

type ExtractComparableKeyFunc

type ExtractComparableKeyFunc[V any, K comparable] func(i int, a V) K

type ExtractKeyFunc

type ExtractKeyFunc[V any] func(i int, a V) interface{}

type FilterFunc

type FilterFunc[V any] func(i int, a V) bool

type MergeValuesFunc

type MergeValuesFunc[V any, W any, VW any] func(okV bool, v V, okW bool, w W) []VW

type PeekFunc

type PeekFunc[V any] func(i int, a V)

type SortFunc

type SortFunc[V any] func(i int, a V, j int, b V) bool

type Stream

type Stream[V any] interface {
	First() (V, bool)
	FirstBy(checkValues FilterFunc[V]) (int, V, bool)
	Last() (V, bool)
	LastBy(checkValues FilterFunc[V]) (int, V, bool)
	Count() int
	AllMatch(checkValues FilterFunc[V]) bool
	AnyMatch(checkValues FilterFunc[V]) bool
	NoneMatch(checkValues FilterFunc[V]) bool
	ForEach(do DoFunc[V]) error
	ForEachAsync(do DoFunc[V]) error
	ForEachChunk(chunkSize int, do DoChunkFunc[V]) error
	ForEachChunkAsync(chunkSize int, do DoChunkFunc[V]) error
	Get() []V
	Reverse() Stream[V]
	Sort(sortValues SortFunc[V]) Stream[V]
	Filter(checkValues FilterFunc[V]) Stream[V]
	Peek(peekValues PeekFunc[V]) Stream[V]
	Expand(remap ExpandFunc[V]) Stream[V]
	Limit(int) Stream[V]
	Skip(int) Stream[V]
	Distinct(compareValues EqFunc[V]) Stream[V]
	DistinctByKey(distinctKey ExtractKeyFunc[V]) Stream[V]
}

func FilterByType added in v1.0.2

func FilterByType[V any, NV any](s Stream[V]) Stream[NV]

func Join

func Join[
	V any,
	W any,
	VW any,
	K comparable](
	sLeft Stream[V],
	extractKeyLeft ExtractComparableKeyFunc[V, K],
	sRight Stream[W],
	extractKeyRight ExtractComparableKeyFunc[W, K],
	merge MergeValuesFunc[V, W, VW]) Stream[VW]

func New

func New[V any](slice ...V) Stream[V]

func Wrap

func Wrap[V any, NV any](s Stream[V], wrapValue WrapValueFunc[V, NV]) Stream[NV]

func Wrap1to1 added in v1.0.1

func Wrap1to1[V any, NV any](s Stream[V], wrapValue Wrap1to1ValueFunc[V, NV]) Stream[NV]

type Wrap1to1ValueFunc added in v1.0.1

type Wrap1to1ValueFunc[V any, NV any] func(i int, value V) NV

type WrapValueFunc

type WrapValueFunc[V any, NV any] func(i int, value V) []NV

Jump to

Keyboard shortcuts

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