1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 00:02:28 +08:00

feat: add UniqueByParallel for slice

This commit is contained in:
dudaodong
2024-08-08 10:20:52 +08:00
parent 9be124211e
commit 356351896d
3 changed files with 122 additions and 0 deletions

View File

@@ -1448,3 +1448,17 @@ func TestRightPaddingAndLeftPadding(t *testing.T) {
padded := LeftPadding(RightPadding(nums, 0, 3), 0, 3)
assert.Equal([]int{0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0}, padded)
}
func TestUniqueByParallel(t *testing.T) {
t.Parallel()
assert := internal.NewAssert(t, "TestUniqueByParallel")
nums := []int{1, 2, 3, 1, 2, 4, 5, 6, 4, 7}
numOfThreads := 4
comparator := func(item int, other int) bool { return item == other }
result := UniqueByParallel(nums, numOfThreads, comparator)
assert.Equal([]int{1, 2, 3, 4, 5, 6, 7}, result)
}