MCPcopy Index your code
hub / github.com/coder/coder / SymmetricDifference

Function SymmetricDifference

coderd/util/slice/slice.go:203–206  ·  view source on GitHub ↗

SymmetricDifference returns the elements that need to be added and removed to get from set 'a' to set 'b'. Note that duplicates are ignored in sets. In classical set theory notation, SymmetricDifference returns all elements of {add} and {remove} together. It is more useful to return them as their ow

(a, b []T)

Source from the content-addressed store, hash-verified

201// fmt.Println(add) // [2]
202// fmt.Println(remove) // [3, 4]
203func SymmetricDifference[T comparable](a, b []T) (add []T, remove []T) {
204 f := func(a, b T) bool { return a == b }
205 return SymmetricDifferenceFunc(a, b, f)
206}
207
208func SymmetricDifferenceFunc[T any](a, b []T, equal func(a, b T) bool) (add []T, remove []T) {
209 // Ignore all duplicates

Callers 4

produceUpdateFunction · 0.92
SyncOrganizationsMethod · 0.92
TestSymmetricDifferenceFunction · 0.92

Calls 1

SymmetricDifferenceFuncFunction · 0.85

Tested by 2

TestSymmetricDifferenceFunction · 0.74