MCPcopy Create free account
hub / github.com/devld/go-drive / ArrayFind

Function ArrayFind

common/utils/utils.go:230–239  ·  view source on GitHub ↗
(a []T, matches func(T, int) bool)

Source from the content-addressed store, hash-verified

228}
229
230func ArrayFind[T any](a []T, matches func(T, int) bool) (ret T, ok bool) {
231 for i := range a {
232 if matches(a[i], i) {
233 ret = a[i]
234 ok = true
235 return
236 }
237 }
238 return
239}
240
241func ArrayKeyBy[KT comparable, T any](a []T, keyFn func(T, int) KT) map[KT]T {
242 m := make(map[KT]T, len(a))

Callers 2

installDriveMethod · 0.92
GetMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected