public void Remove(TKey key1, TKey key2) { var oneKey = new MultiKey <TKey>(key1, key2); var twoKey = new MultiKey <TKey>(key2, key1); base.Remove(oneKey); base.Remove(twoKey); ArrayData.Remove(key1); ArrayData.Remove(key2); }
public new void Remove(MultiKey <TKey> key) { var oneKey = new MultiKey <TKey>(key.Item1, key.Item2); var twoKey = new MultiKey <TKey>(key.Item2, key.Item1); base.Remove(oneKey); base.Remove(twoKey); ArrayData.Remove(key.Item1); ArrayData.Remove(key.Item2); }
public bool ContainsKey(TKey key1, TKey key2) { var oneKey = new MultiKey <TKey>(key1, key2); var twoKey = new MultiKey <TKey>(key2, key1); if (ContainsKey(oneKey) || ContainsKey(twoKey)) { return(true); } return(false); }
public TValue Get(TKey key1, TKey key2) { var oneKey = new MultiKey <TKey>(key1, key2); var twoKey = new MultiKey <TKey>(key2, key1); if (ContainsKey(oneKey)) { return(this[oneKey]); } else if (ContainsKey(twoKey)) { return(this[twoKey]); } return(default);
// 如果没有,则会自动添加一个 public void Change(TKey key1, TKey key2, TValue value) { var oneKey = new MultiKey <TKey>(key1, key2); var twoKey = new MultiKey <TKey>(key2, key1); if (ContainsKey(oneKey)) { this[oneKey] = value; } else { this[twoKey] = value; } if (!ArrayData.ContainsKey(key1)) { ArrayData[key1] = new Dictionary <TKey, TValue>(); } if (!ArrayData.ContainsKey(key2)) { ArrayData[key2] = new Dictionary <TKey, TValue>(); } ArrayData[key1][key2] = value; ArrayData[key2][key1] = value; }