MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / SliceFilter

Function SliceFilter

pkg/util/util.go:58–66  ·  view source on GitHub ↗

SliceFilter takes an input collection and returns elements where `predicate` returns true Known as 'filter' in most other languages or 'Select' in C# Linq.

(slice []T, predicate func(item T) bool)

Source from the content-addressed store, hash-verified

56// SliceFilter takes an input collection and returns elements where `predicate` returns true
57// Known as 'filter' in most other languages or 'Select' in C# Linq.
58func SliceFilter[T any](slice []T, predicate func(item T) bool) []T {
59 var results []T = nil
60 for _, item := range slice {
61 if predicate(item) {
62 results = append(results, item)
63 }
64 }
65 return results
66}
67
68func SliceExcept[T any](slice []T, predicate func(item T) bool) []T {
69 return SliceFilter(slice, func(item T) bool { return !predicate(item) })

Callers 15

findTenantsAndTagsFunction · 0.92
AskQuestionsFunction · 0.92
findReleasesFunction · 0.92
DeleteRunFunction · 0.92
viewRunFunction · 0.92
getVariableFunction · 0.92
excludeRunFunction · 0.92
PromptMissingFunction · 0.92
includeRunFunction · 0.92
projectSelectorFunction · 0.92
GetAllGitReferencesFunction · 0.92
getAllWorkerPoolsFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected