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.
CrowdControl/Assets/3rd/Plugins/Smart-Inspector/Base/Utils/DictionaryUtils.cs

27 lines
829 B
C#

3 months ago
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;
}
}
}