aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
index aab5595da..242d06cf0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
@@ -13,6 +13,12 @@ class TimeLimitedSet<T : Any>(
cache[element] = Unit
}
+ fun addIfAbsent(element: T) {
+ if (!contains(element)) add(element)
+ }
+
+ fun remove(element: T) = cache.remove(element)
+
operator fun contains(element: T): Boolean = cache.containsKey(element)
fun clear() = cache.clear()