mirror of https://github.com/portainer/portainer
feat(api): remove golang experimental packages [EE-3648] (#8081)
* remove golang experimental packages * rebase and fix referencespull/8172/head
parent
dffd45c5f9
commit
3e485c3152
@ -0,0 +1,22 @@
|
|||||||
|
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 {
|
||||||
|
for _, s := range elems {
|
||||||
|
if v == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 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 {
|
||||||
|
for i, v := range s {
|
||||||
|
if f(v) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
Loading…
Reference in new issue