group

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count[T any](batch int, p ...*T) int

Count函数用于计算切片p中元素的批次数量。 参数batch表示每个批次的元素数量。 参数p为切片指针,切片中的元素类型为any。 返回值为int类型,表示切片p中的元素能够组成的批次数量。

func CountBase added in v0.3.73

func CountBase[T any](batch int, p ...T) int

func Group

func Group[T any](batch int, p ...*T) [][]*T

Group函数将给定的切片p按照batch的大小进行分组,并返回分组后的结果。 参数:

  • batch:每个分组的大小
  • p:需要分组的切片

返回值:

  • [][]*T:分组后的结果,每个子切片表示一个分组

func GroupBase added in v0.3.73

func GroupBase[T any](batch int, p ...T) [][]T

func GroupBaseFunc added in v0.3.73

func GroupBaseFunc[T any](f func(v ...T) (int64, error), batch int, p ...T) (int64, map[int]error)

func GroupFunc

func GroupFunc[T any](f func(v ...*T) (int64, error), batch int, p ...*T) (int64, map[int]error)

GroupFunc是一个并发执行函数的工具函数。 它接受一个函数f作为参数,该函数接受可变数量的指向T类型的指针作为参数,并返回一个int64和一个error。 batch参数指定了并发执行的批次大小。 p参数是一个可变参数列表,用于指定函数f的参数。 函数返回一个int64和一个map[int]error,分别表示所有并发执行的函数的总影响量和每个并发执行的函数的错误信息。

func Section added in v0.3.70

func Section(beg, end, step int64) [][]int64

func SectionAny added in v0.3.70

func SectionAny[T ISection](root ISection, step int64, f func(int64, int64) T) []T

Types

type ISection added in v0.3.70

type ISection interface {
	GetBeg() int64
	GetEnd() int64
}

Jump to

Keyboard shortcuts

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