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

Function SameElements

coderd/util/slice/slice.go:60–71  ·  view source on GitHub ↗

SameElements returns true if the 2 lists have the same elements in any order.

(a []T, b []T)

Source from the content-addressed store, hash-verified

58// SameElements returns true if the 2 lists have the same elements in any
59// order.
60func SameElements[T comparable](a []T, b []T) bool {
61 if len(a) != len(b) {
62 return false
63 }
64
65 for _, element := range a {
66 if !Contains(b, element) {
67 return false
68 }
69 }
70 return true
71}
72
73func ContainsCompare[T any](haystack []T, needle T, equal func(a, b T) bool) bool {
74 for _, hay := range haystack {

Callers 6

convertToWorkspaceRoleFunction · 0.92
convertToChatRoleFunction · 0.92
EqualMethod · 0.92
TestSameElementsFunction · 0.92
assertSameElementsFunction · 0.92
convertToTemplateRoleFunction · 0.92

Calls 1

ContainsFunction · 0.85

Tested by 2

TestSameElementsFunction · 0.74
assertSameElementsFunction · 0.74