From efdd850e77fe32261038532800e18f6164e45fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 27 Nov 2025 15:18:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E4=BB=B6=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E6=95=B0=E6=8D=AE=E6=8C=89=E7=85=A7=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E8=BF=9B=E8=A1=8C=E5=88=86=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- op_array/util.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/op_array/util.go b/op_array/util.go index 5eec209..2c3627b 100644 --- a/op_array/util.go +++ b/op_array/util.go @@ -144,3 +144,16 @@ func DeepClone[Value any](dataList []Value) []Value { } return res } + +// Shard 将数组按照指定数量进行分片 +func Shard[Value any](dataList []Value, itemShardCount int) [][]Value { + res := make([][]Value, 0) + for i := 0; i < len(dataList); i += itemShardCount { + tmpList := make([]Value, 0) + for j := 0; j < itemShardCount; j++ { + tmpList = append(tmpList, dataList[i+j]) + } + res = append(res, tmpList) + } + return res +}