mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
adproperties now has transforms list; assembler can make transformed skeleton
new fun: LinearSearch(By)
This commit is contained in:
@@ -724,3 +724,18 @@ fun interpolateLinear(scale: Double, startValue: Double, endValue: Double): Doub
|
||||
}
|
||||
return (1.0 - scale) * startValue + scale * endValue
|
||||
}
|
||||
|
||||
fun <T> List<T>.linearSearch(selector: (T) -> Boolean): Int? {
|
||||
this.forEachIndexed { index, it ->
|
||||
if (selector.invoke(it)) return index
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
fun <T> List<T>.linearSearchBy(selector: (T) -> Boolean): T? {
|
||||
this.forEach {
|
||||
if (selector.invoke(it)) return it
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user