Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use same function for all types
  • Loading branch information
Emyrk committed Aug 22, 2024
commit ed8972f3334f7e05da7dc7ba99e76cafaf1a93a1
10 changes: 2 additions & 8 deletions coderd/util/slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,8 @@ func Descending[T constraints.Ordered](a, b T) int {
// fmt.Println(add) // [2]
// fmt.Println(remove) // [3, 4]
func SymmetricDifference[T comparable](a, b []T) (add []T, remove []T) {
return Difference(b, a), Difference(a, b)
}

// Difference returns the elements in 'a' that are not in 'b'.
func Difference[T comparable](a []T, b []T) []T {
return DifferenceFunc(a, b, func(a, b T) bool {
return a == b
})
f := func(a, b T) bool { return a == b }
return SymmetricDifferenceFunc(a, b, f)
}

func SymmetricDifferenceFunc[T any](a, b []T, equal func(a, b T) bool) (add []T, remove []T) {
Expand Down
Loading