2 using System.Collections;
3 using System.Collections.Generic;
9 private readonly Dictionary<T1, T2> t1ToT2 =
new Dictionary<T1, T2>();
10 private readonly Dictionary<T2, T1> t2ToT1 =
new Dictionary<T2, T1>();
14 return t1ToT2.ContainsKey(t1);
19 return t2ToT1.ContainsKey(t2);
24 get {
return t1ToT2[t1]; }
27 T2 prevT2 = t1ToT2[t1];
28 t2ToT1.Remove(prevT2); t2ToT1.Add(value, t1);
35 get {
return t2ToT1[t2]; }
38 T1 prevT1 = t2ToT1[t2];
39 t1ToT2.Remove(prevT1); t1ToT2.Add(value, t2);
44 public void Add(T1 t1, T2 t2)
46 if (
Contains(t1)) {
throw new ArgumentException($
"{GetType().Name} already contains {t1}"); }
47 if (
Contains(t2)) {
throw new ArgumentException($
"{GetType().Name} already contains {t2}"); }
68 foreach (var t1
in t1ToT2.Keys)
70 yield
return (t1, t1ToT2[t1]);
74 IEnumerator IEnumerable.GetEnumerator()
IEnumerator<(T1, T2)> GetEnumerator()