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

refactor: rename ReverseIntersect to SymmetricDifference

This commit is contained in:
dudaodong
2022-04-01 18:05:02 +08:00
parent 21dd6ab8aa
commit 3c16d50c4b
2 changed files with 7 additions and 7 deletions

View File

@@ -602,8 +602,8 @@ func Intersection[T any](slices ...[]T) []T {
return Unique(res) return Unique(res)
} }
// ReverseIntersect reverse operation of Intersection function // SymmetricDifference oppoiste operation of intersection function
func ReverseIntersect[T any](slices ...[]T) []T { func SymmetricDifference[T any](slices ...[]T) []T {
if len(slices) == 0 { if len(slices) == 0 {
return []T{} return []T{}
} }

View File

@@ -409,16 +409,16 @@ func TestIntersection(t *testing.T) {
} }
} }
func TestReverseIntersect(t *testing.T) { func TestSymmetricDifference(t *testing.T) {
assert := internal.NewAssert(t, "TestIntersection") assert := internal.NewAssert(t, "TestSymmetricDifference")
s1 := []int{1, 2, 3} s1 := []int{1, 2, 3}
s2 := []int{1, 2, 4} s2 := []int{1, 2, 4}
s3 := []int{1, 2, 3, 5} s3 := []int{1, 2, 3, 5}
assert.Equal([]int{1, 2, 3}, ReverseIntersect(s1)) assert.Equal([]int{1, 2, 3}, SymmetricDifference(s1))
assert.Equal([]int{3, 4}, ReverseIntersect(s1, s2)) assert.Equal([]int{3, 4}, SymmetricDifference(s1, s2))
assert.Equal([]int{3, 4, 5}, ReverseIntersect(s1, s2, s3)) assert.Equal([]int{3, 4, 5}, SymmetricDifference(s1, s2, s3))
} }
func TestReverse(t *testing.T) { func TestReverse(t *testing.T) {