mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-06 13:42:28 +08:00
refactor: rename ReverseIntersect to SymmetricDifference
This commit is contained in:
@@ -602,8 +602,8 @@ func Intersection[T any](slices ...[]T) []T {
|
||||
return Unique(res)
|
||||
}
|
||||
|
||||
// ReverseIntersect reverse operation of Intersection function
|
||||
func ReverseIntersect[T any](slices ...[]T) []T {
|
||||
// SymmetricDifference oppoiste operation of intersection function
|
||||
func SymmetricDifference[T any](slices ...[]T) []T {
|
||||
if len(slices) == 0 {
|
||||
return []T{}
|
||||
}
|
||||
|
||||
@@ -409,16 +409,16 @@ func TestIntersection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReverseIntersect(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestIntersection")
|
||||
func TestSymmetricDifference(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestSymmetricDifference")
|
||||
|
||||
s1 := []int{1, 2, 3}
|
||||
s2 := []int{1, 2, 4}
|
||||
s3 := []int{1, 2, 3, 5}
|
||||
|
||||
assert.Equal([]int{1, 2, 3}, ReverseIntersect(s1))
|
||||
assert.Equal([]int{3, 4}, ReverseIntersect(s1, s2))
|
||||
assert.Equal([]int{3, 4, 5}, ReverseIntersect(s1, s2, s3))
|
||||
assert.Equal([]int{1, 2, 3}, SymmetricDifference(s1))
|
||||
assert.Equal([]int{3, 4}, SymmetricDifference(s1, s2))
|
||||
assert.Equal([]int{3, 4, 5}, SymmetricDifference(s1, s2, s3))
|
||||
}
|
||||
|
||||
func TestReverse(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user