mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
feat(custom-templates): filter templates by edge [EE-6565] (#10979)
This commit is contained in:
parent
441a8bbbbf
commit
2826a4ce39
10 changed files with 229 additions and 21 deletions
|
@ -8,3 +8,16 @@ func Map[T, U any](s []T, f func(T) U) []U {
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Filter returns a new slice containing only the elements of the slice for which the given predicate returns true
|
||||
func Filter[T any](s []T, predicate func(T) bool) []T {
|
||||
n := 0
|
||||
for _, v := range s {
|
||||
if predicate(v) {
|
||||
s[n] = v
|
||||
n++
|
||||
}
|
||||
}
|
||||
|
||||
return s[:n]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue