mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 11:57:39 +03:00
Add FindIndexed
This commit is contained in:
parent
2812461739
commit
00f3153336
1 changed files with 9 additions and 0 deletions
|
@ -130,6 +130,15 @@ func Find[T any](arr []T, block func(it T) bool) T {
|
|||
return DefaultValue[T]()
|
||||
}
|
||||
|
||||
func FindIndexed[T any](arr []T, block func(index int, it T) bool) T {
|
||||
for i, it := range arr {
|
||||
if block(i, it) {
|
||||
return it
|
||||
}
|
||||
}
|
||||
return DefaultValue[T]()
|
||||
}
|
||||
|
||||
//go:norace
|
||||
func Dup[T any](obj T) T {
|
||||
if UnsafeBuffer {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue