Added FindWithIndexWhere
All checks were successful
ci / deploy (push) Successful in 1m2s

This commit is contained in:
Leon Mika 2025-06-19 13:23:00 +02:00
parent f285d1f8e0
commit 0be0b6b35b

View file

@ -19,3 +19,14 @@ func FindWhere[T comparable](ts []T, predicate func(t T) bool) (T, bool) {
}
return zeroT, false
}
func FindWithIndexWhere[T comparable](ts []T, predicate func(t T) bool) (T, int, bool) {
var zeroT T
for i, t := range ts {
if predicate(t) {
return t, i, true
}
}
return zeroT, 0, false
}