aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-18 20:00:47 +0100
committerLinnea Gräf <nea@nea.moe>2024-01-18 20:00:47 +0100
commit608fec9cd0bbe3cf389faaeb7e258b592e3adf14 (patch)
treeef7996342498f64529ac6eb5851b2a61a1973d1c /src/main/kotlin/moe/nea/firmament/util
parentd7902e06cd7285c72cd4ea2be6f18ead56a8775e (diff)
downloadFirmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.gz
Firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.tar.bz2
Firmament-608fec9cd0bbe3cf389faaeb7e258b592e3adf14.zip
Add Nearby Burrow Highlighter
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/MutableMapWithMaxSize.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/MutableMapWithMaxSize.kt b/src/main/kotlin/moe/nea/firmament/util/MutableMapWithMaxSize.kt
new file mode 100644
index 0000000..8032053
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/util/MutableMapWithMaxSize.kt
@@ -0,0 +1,13 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.util
+
+fun <K, V> mutableMapWithMaxSize(maxSize: Int): MutableMap<K, V> = object : LinkedHashMap<K, V>() {
+ override fun removeEldestEntry(eldest: MutableMap.MutableEntry<K, V>): Boolean {
+ return size > maxSize
+ }
+}