public bool Equals(DoubleKeyDictionary <K, T, V> other) { if (OuterDictionary.Keys.Count != other.OuterDictionary.Keys.Count) { return(false); } bool isEqual = true; foreach (KeyValuePair <K, Dictionary <T, V> > innerItems in OuterDictionary) { if (!other.OuterDictionary.ContainsKey(innerItems.Key)) { isEqual = false; } if (!isEqual) { break; } // here we can be sure that the key is in both lists, // but we need to check the contents of the inner dictionary Dictionary <T, V> otherInnerDictionary = other.OuterDictionary[innerItems.Key]; foreach (KeyValuePair <T, V> innerValue in innerItems.Value) { if (!otherInnerDictionary.ContainsValue(innerValue.Value)) { isEqual = false; } if (!otherInnerDictionary.ContainsKey(innerValue.Key)) { isEqual = false; } } if (!isEqual) { break; } } return(isEqual); }
protected Matrix() { headerRows = new List <Cell <TItem> >(); headerColumns = new List <Cell <TItem> >(); cache = new DoubleKeyDictionary <TItem, TItem, TValue>(); }