You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
829 B
C#
27 lines
829 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AV.Inspector
|
|
{
|
|
internal static class DictionaryUtils
|
|
{
|
|
public static void TryRemove<TKey, TValue>(this Dictionary<TKey, TValue> lookup, TKey key)
|
|
{
|
|
if (lookup.ContainsKey(key))
|
|
lookup.Remove(key);
|
|
}
|
|
public static void TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> lookup, TKey key, TValue value)
|
|
{
|
|
if (!lookup.ContainsKey(key))
|
|
lookup.Add(key, value);
|
|
}
|
|
|
|
public static void AddOrAssign<TKey, TValue>(this Dictionary<TKey, TValue> lookup, TKey key, TValue value)
|
|
{
|
|
if (!lookup.ContainsKey(key))
|
|
lookup.Add(key, value);
|
|
else
|
|
lookup[key] = value;
|
|
}
|
|
}
|
|
} |