mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
25 lines
445 B
Go
25 lines
445 B
Go
package cmptest
|
|
|
|
type slicer[T any] interface {
|
|
ToSlice(sorter ...func(a, b T) int) []T
|
|
}
|
|
|
|
func buildSetComparer[T any, S slicer[T]](l func(x, y T) bool, sorters ...func(a, b T) int) func(x, y S) bool {
|
|
return func(x, y S) bool {
|
|
xs := x.ToSlice(sorters...)
|
|
ys := y.ToSlice(sorters...)
|
|
|
|
if len(xs) != len(ys) {
|
|
return false
|
|
}
|
|
for i, xe := range xs {
|
|
ye := ys[i]
|
|
if !l(xe, ye) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
}
|