diff --git a/AOC.Common/DefaultDictionary.cs b/AOC.Common/DefaultDictionary.cs deleted file mode 100644 index 3b8298b..0000000 --- a/AOC.Common/DefaultDictionary.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace AOC.Common; - -public class DefaultDictionary : Dictionary where TValue : new() where TKey : notnull -{ - public new TValue this[TKey key] - { - get - { - if (TryGetValue(key, out var val)) return val; - val = new(); - Add(key, val); - return val; - } - set => base[key] = value; - } -} \ No newline at end of file diff --git a/AOC.Common/Trees.cs b/AOC.Common/Trees.cs index 30e4d2b..56a3a5d 100644 --- a/AOC.Common/Trees.cs +++ b/AOC.Common/Trees.cs @@ -1,6 +1,6 @@ namespace AOC.Common; -public class DefaultDict : Dictionary where TKey : notnull +public class DefaultDictionary : Dictionary where TKey : notnull { public TValue? DefaultValue; @@ -81,7 +81,7 @@ public class Dijkstra where TCell : notnull public int ComputeFind(TCell start, TCell target, Func? valid = null) { valid ??= _ => true; - var dist = new DefaultDict { DefaultValue = int.MaxValue, [start] = 0 }; + var dist = new DefaultDictionary { DefaultValue = int.MaxValue, [start] = 0 }; var seen = new HashSet(); var queue = new PriorityQueue(); queue.Enqueue(start, 0);