Documentation
¶
Index ¶
- func ForEach[T any](collection []T, iteratee func(T, int), options ...*Option)
- func GroupBy[T any, U comparable](collection []T, iteratee func(T) U, options ...*Option) map[U][]T
- func Map[T any, R any](collection []T, iteratee func(T, int) R, options ...*Option) []R
- func PartitionBy[T any, K comparable](collection []T, iteratee func(x T) K, options ...*Option) [][]T
- func Times[T any](count int, iteratee func(int) T, options ...*Option) []T
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEach ¶
ForEach iterates over elements of collection and invokes iteratee for each element. `iteratee` is call in parallel. You also can control the conurrency limit by optional ParallelOption to limit the maximum number of concurrent `iteratee` goroutines running at the same time, just like `parallel.ForEach(list, iteratee, parallel.Option().Concurrency(10))`.
func GroupBy ¶
func GroupBy[T any, U comparable](collection []T, iteratee func(T) U, options ...*Option) map[U][]T
GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee. `iteratee` is call in parallel. You also can control the conurrency limit by optional ParallelOption to limit the maximum number of concurrent `iteratee` goroutines running at the same time, just like `parallel.GroupBy(list, iteratee, parallel.Option().Concurrency(10))`.
func Map ¶
Map manipulates a slice and transforms it to a slice of another type. `iteratee` is call in parallel. Result keep the same order. You also can control the conurrency limit by optional ParallelOption to limit the maximum number of concurrent `iteratee` goroutines running at the same time, just like `parallel.Map(list, iteratee, parallel.Option().Concurrency(10))`.
func PartitionBy ¶
func PartitionBy[T any, K comparable](collection []T, iteratee func(x T) K, options ...*Option) [][]T
PartitionBy returns an array of elements split into groups. The order of grouped values is determined by the order they occur in collection. The grouping is generated from the results of running each element of collection through iteratee. `iteratee` is call in parallel. You also can control the conurrency limit by optional ParallelOption to limit the maximum number of concurrent `iteratee` goroutines running at the same time, just like `parallel.PartitionBy(list, iteratee, parallel.Option().Concurrency(10))`.
func Times ¶
Times invokes the iteratee n times, returning an array of the results of each invocation. The iteratee is invoked with index as argument. `iteratee` is call in parallel. You also can control the conurrency limit by optional ParallelOption to limit the maximum number of concurrent `iteratee` goroutines running at the same time, just like `parallel.Times(count, iteratee, parallel.Option().Concurrency(10))`.
Types ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option provides some useful configure options for parallel, such as conurrency limit.
func WithConcurrency ¶
WithConcurrency create an ParallelOption and set the maximum number of concurrent `iteratee` goroutines running at the same time.
func (*Option) WithConcurrency ¶
WithConcurrency() set the maximum number of concurrent `iteratee` goroutines running at the same time.