mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-11 03:15:44 +02:00
Add Iterator.any & Iterator.find extensions
This commit is contained in:
parent
2eeb1f13ae
commit
a2f14d8c39
21
src/main/java/chylex/hee/system/util/CollectionExt.kt
Normal file
21
src/main/java/chylex/hee/system/util/CollectionExt.kt
Normal file
@ -0,0 +1,21 @@
|
||||
package chylex.hee.system.util
|
||||
|
||||
inline fun <T> Iterator<T>.any(predicate: (T) -> Boolean): Boolean{
|
||||
for(element in this){
|
||||
if (predicate(element)){
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
inline fun <T> Iterator<T>.find(predicate: (T) -> Boolean): T?{
|
||||
for(element in this){
|
||||
if (predicate(element)){
|
||||
return element
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
Loading…
Reference in New Issue
Block a user