31
}
32
34
>
aValue := reflect.ValueOf(listA)
35
>
bValue := reflect.ValueOf(listB)
36
>
37
>
aLen := aValue.Len()
38
>
bLen := bValue.Len()
39
>
40
>
// Mark indexes in bValue that we already used
41
>
visited := make([]bool, bLen)
42
>
for i := range aLen {
43
>
element := aValue.Index(i).Interface()
44
>
found := false
45
>
for j := range bLen {
46
>
if visited[j] {
47
>
continue
48
}
50
>
visited[j] = true
51
>
found = true
52
>
break
53
}
54
}
56
extraA = append(extraA, element)
57
}
58
}
59
61
>
if visited[j] {
62
>
continue
63
}
64
extraB = append(extraB, bValue.Index(j).Interface())
65
}
66
68
}
69
71
>
72
>
// get nil case out of the way
73
>
if object == nil {
74
return true
75
}
76
78
>
79
>
switch objValue.Kind() {
80
// collection types are empty when they have no element
82
>
return objValue.Len() == 0
83
// pointers are empty if nil or if the value they point to is empty
84
case reflect.Pointer: