using System.Collections; using System.Collections.Generic; using UnityEngine; public static class DoubleDictionary{ static Dictionary keys; static Dictionary values; static DoubleDictionary(){ Create(); } public static void Create(){ keys = new Dictionary(); values = new Dictionary(); } public static void Set(Key key, Value value){ keys.Add(key, value); values.Add(value, key); } public static void Remove(Key key){ Value value; if (keys.TryGetValue(key, out value)){ keys.Remove(key); values.Remove(value); } } public static void Remove(Value value){ Key key; if (values.TryGetValue(value, out key)){ keys.Remove(key); values.Remove(value); } } public static void Remove(Key key, Value value){ keys.Remove(key); values.Remove(value); } public static Key Get(Value value){ Key key; return values.TryGetValue(value, out key) ? key : default; } public static Value Get(Key key){ Value value; return keys.TryGetValue(key, out value) ? value : default; } }