Documentation
¶
Overview ¶
Package parallel provides versions of slicex functions that execute in parallel.
Index ¶
- func Apply[S ~[]T, T any](slice S, apply func(item T))
- func ApplyWithLimit[S ~[]T, T any](slice S, apply func(item T), concurrency int)
- func GroupBy[S ~[]T, T any, R comparable](slice S, predicate func(item T) R) map[R]S
- func GroupByWithLimit[S ~[]T, T any, R comparable](slice S, predicate func(item T) R, concurrency int) map[R]S
- func Map[S ~[]T, T any, R any](slice S, mapper func(item T) R) []R
- func MapWithLimit[S ~[]T, T any, R any](slice S, mapper func(item T) R, concurrency int) []R
- func Partition[S ~[]T, T any](slice S, predicate func(item T) bool) (S, S)
- func PartitionWithLimit[S ~[]T, T any](slice S, predicate func(item T) bool, concurrency int) (S, S)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply[S ~[]T, T any](slice S, apply func(item T))
Apply applies a function to each item in the slice. The apply function is called in parallel.
func ApplyWithLimit ¶ added in v0.9.4
ApplyWithLimit applies a function to each item in the slice. The apply function is called in parallel with a max concurrency.
func GroupBy ¶
func GroupBy[S ~[]T, T any, R comparable](slice S, predicate func(item T) R) map[R]S
GroupBy returns a map of slices grouped by a key produced by a predicate function. The predicate is called in parallel, and the results are returned in the order they appear in the slice.
func GroupByWithLimit ¶ added in v0.9.4
func GroupByWithLimit[S ~[]T, T any, R comparable](slice S, predicate func(item T) R, concurrency int) map[R]S
GroupByWithLimit returns a map of slices grouped by a key produced by a predicate function. The predicate is called in parallel with a max concurrency, and the results are returned in the order they appear in the slice.
func Map ¶
Map transforms a slice to a slice of another type using a mapper function. The mapper function is called in parallel, and results are returned in order they appear in the slice.
func MapWithLimit ¶ added in v0.9.4
MapWithLimit transforms a slice to a slice of another type using a mapper function with a max concurrency. The mapper function is called in parallel, and results are returned in order they appear in the slice.
func Partition ¶
Partition splits a slice into two slices based on a predicate. The predicate is called in parallel, and the results are returned in the order they appear in the slice.
func PartitionWithLimit ¶ added in v0.9.4
func PartitionWithLimit[S ~[]T, T any](slice S, predicate func(item T) bool, concurrency int) (S, S)
PartitionWithLimit splits a slice into two slices based on a predicate. The predicate is called in parallel with a max concurrency, and the results are returned in the order they appear in the slice.
Types ¶
This section is empty.