Skip to content

Commit

Permalink
Update slice.DeepEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
arybolovlev committed Jan 4, 2024
1 parent aeee0e5 commit 9e2f31f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ func DeepEqual[A any](a, b []A) bool {
return false
}

for _, va := range a {
ma := make(map[int]any)
mb := make(map[int]any)

for i := 0; i < len(a); i++ {
ma[i] = a[i]
mb[i] = b[i]
}

for _, va := range ma {
found := false
for ib, vb := range b {
for kb, vb := range mb {
if cmp.Equal(va, vb) {
b = RemoveFromSlice(b, ib)
delete(mb, kb)
found = true
break
}
Expand Down

0 comments on commit 9e2f31f

Please sign in to comment.