mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(edge/stacks): increase status transparency [EE-5554] (#9094)
This commit is contained in:
parent
db61fb149b
commit
0bcb57568c
45 changed files with 1305 additions and 316 deletions
|
@ -2,14 +2,33 @@ package slices
|
|||
|
||||
// Contains is a generic function that returns true if the element is contained within the slice
|
||||
func Contains[T comparable](elems []T, v T) bool {
|
||||
return ContainsFunc(elems, func(s T) bool {
|
||||
return s == v
|
||||
})
|
||||
}
|
||||
|
||||
// Contains is a generic function that returns true if the element is contained within the slice
|
||||
func ContainsFunc[T any](elems []T, f func(T) bool) bool {
|
||||
for _, s := range elems {
|
||||
if v == s {
|
||||
if f(s) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Find[T any](elems []T, f func(T) bool) (T, bool) {
|
||||
for _, s := range elems {
|
||||
if f(s) {
|
||||
return s, true
|
||||
}
|
||||
}
|
||||
|
||||
// return default value
|
||||
var result T
|
||||
return result, false
|
||||
}
|
||||
|
||||
// IndexFunc returns the first index i satisfying f(s[i]),
|
||||
// or -1 if none do.
|
||||
func IndexFunc[E any](s []E, f func(E) bool) int {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue