aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/collections/listutil.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-09-24 11:40:15 +0200
committerLinnea Gräf <nea@nea.moe>2024-09-24 11:40:15 +0200
commit420f2a61e1cc64d68bf03825e8fd70cf49ac6a01 (patch)
tree540f2beaf99bda96af3c145cbfe81faebba76bee /src/main/kotlin/util/collections/listutil.kt
parent64099bd2628490b06392766c6d1b9425f26788a3 (diff)
downloadFirmament-420f2a61e1cc64d68bf03825e8fd70cf49ac6a01.tar.gz
Firmament-420f2a61e1cc64d68bf03825e8fd70cf49ac6a01.tar.bz2
Firmament-420f2a61e1cc64d68bf03825e8fd70cf49ac6a01.zip
Use weak caches for custom textures
Diffstat (limited to 'src/main/kotlin/util/collections/listutil.kt')
-rw-r--r--src/main/kotlin/util/collections/listutil.kt9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/kotlin/util/collections/listutil.kt b/src/main/kotlin/util/collections/listutil.kt
new file mode 100644
index 0000000..7f85a30
--- /dev/null
+++ b/src/main/kotlin/util/collections/listutil.kt
@@ -0,0 +1,9 @@
+
+package moe.nea.firmament.util.collections
+
+fun <T, R> List<T>.lastNotNullOfOrNull(func: (T) -> R?): R? {
+ for (i in indices.reversed()) {
+ return func(this[i]) ?: continue
+ }
+ return null
+}