MultiKeyDictionary.cs 589 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class MultiKeyDictionary<T1, T2, T3> : Dictionary<T1, Dictionary<T2, T3>>
  5. {
  6. new public Dictionary<T2, T3> this[T1 key]
  7. {
  8. get
  9. {
  10. if (!ContainsKey(key))
  11. Add(key, new Dictionary<T2, T3>());
  12. Dictionary<T2, T3> returnObj;
  13. TryGetValue(key, out returnObj);
  14. return returnObj;
  15. }
  16. }
  17. public bool ContainsKey(T1 key1, T2 key2)
  18. {
  19. Dictionary<T2, T3> returnObj;
  20. TryGetValue(key1, out returnObj);
  21. if (returnObj == null)
  22. return false;
  23. return returnObj.ContainsKey(key2);
  24. }
  25. }