MCPcopy Create free account
hub / github.com/eth-easl/dirigent / Difference

Function Difference

pkg/map/maps.go:47–62  ·  view source on GitHub ↗
(a, b []T)

Source from the content-addressed store, hash-verified

45}
46
47func Difference[T comparable](a, b []T) []T {
48 mb := make(map[T]struct{}, len(b))
49 for _, x := range b {
50 mb[x] = struct{}{}
51 }
52
53 var diff []T
54
55 for _, x := range a {
56 if _, found := mb[x]; !found {
57 diff = append(diff, x)
58 }
59 }
60
61 return diff
62}
63
64func ExtractField[T any](m []T, extractor func(T) string) ([]string, map[string]T) {
65 var res []string

Callers 2

TestDifferenceFunction · 0.85
TestDifferenceSecondFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestDifferenceFunction · 0.68
TestDifferenceSecondFunction · 0.68