about summary refs log tree commit diff
path: root/LibMatrix/Extensions/DictionaryExtensions.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:16:40 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:16:40 +0200
commit1d02d9d76d987b69ed08a252a3fa66f7d05a4cbc (patch)
tree27314b621fa27045dcb375da9df9fde374d3c69d /LibMatrix/Extensions/DictionaryExtensions.cs
parentCode cleanup (diff)
downloadLibMatrix-1d02d9d76d987b69ed08a252a3fa66f7d05a4cbc.tar.xz
Clean up some extension functions
Diffstat (limited to 'LibMatrix/Extensions/DictionaryExtensions.cs')
-rw-r--r--LibMatrix/Extensions/DictionaryExtensions.cs32
1 files changed, 0 insertions, 32 deletions
diff --git a/LibMatrix/Extensions/DictionaryExtensions.cs b/LibMatrix/Extensions/DictionaryExtensions.cs
deleted file mode 100644
index f01cf68..0000000
--- a/LibMatrix/Extensions/DictionaryExtensions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace LibMatrix.Extensions;
-
-public static class DictionaryExtensions {
-    public static bool ChangeKey<TKey, TValue>(this IDictionary<TKey, TValue> dict,
-        TKey oldKey, TKey newKey) {
-        if (!dict.Remove(oldKey, out var value))
-            return false;
-
-        dict[newKey] = value; // or dict.Add(newKey, value) depending on ur comfort
-        return true;
-    }
-
-    public static Y GetOrCreate<X, Y>(this IDictionary<X, Y> dict, X key) where Y : new() {
-        if (dict.TryGetValue(key, out var value)) {
-            return value;
-        }
-
-        value = new Y();
-        dict.Add(key, value);
-        return value;
-    }
-
-    public static Y GetOrCreate<X, Y>(this IDictionary<X, Y> dict, X key, Func<X, Y> valueFactory) {
-        if (dict.TryGetValue(key, out var value)) {
-            return value;
-        }
-
-        value = valueFactory(key);
-        dict.Add(key, value);
-        return value;
-    }
-}