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

Function Filter

coderd/util/slice/slice.go:113–121  ·  view source on GitHub ↗

Filter returns all elements that satisfy the condition.

(haystack []T, cond func(T) bool)

Source from the content-addressed store, hash-verified

111
112// Filter returns all elements that satisfy the condition.
113func Filter[T any](haystack []T, cond func(T) bool) []T {
114 out := make([]T, 0, len(haystack))
115 for _, hay := range haystack {
116 if cond(hay) {
117 out = append(out, hay)
118 }
119 }
120 return out
121}
122
123// Overlap returns if the 2 sets have any overlap (element(s) in common)
124func Overlap[T comparable](a []T, b []T) bool {

Callers 11

filterMessageEventsFunction · 0.92
FilterByPresetMethod · 0.92
TestFilterFunction · 0.92
TestExpTaskListFunction · 0.92
WorkspaceResourcesFunction · 0.92
allJobStatusesExceptFunction · 0.92
TestTimingsFromProvisionFunction · 0.92
GetUnmetDependenciesMethod · 0.92
StopMethod · 0.92
RemoveMethod · 0.92

Calls

no outgoing calls

Tested by 7

filterMessageEventsFunction · 0.74
TestFilterFunction · 0.74
TestExpTaskListFunction · 0.74
allJobStatusesExceptFunction · 0.74
TestTimingsFromProvisionFunction · 0.74
StopMethod · 0.74
RemoveMethod · 0.74