/// /// <summary> * equals - Compares two maps, returns true if content equal, otherwise false.<br> If input is not of type /// * JDFAttributeMap, the result of the superclasses' equals method is returned. /// * </summary> /// * <param name="obj"> JDFAttributeMap to compare with <code>this</code> /// * </param> /// * <returns> boolean - true if the maps are equal, otherwise false </returns> /// public override bool Equals(object other) { if (this == other) { return(true); } if (other == null || !(other is JDFAttributeMap)) { return(false); } JDFAttributeMap otherMap = (JDFAttributeMap)other; if (this.Count != otherMap.Count) { return(false); } foreach (string key in this.Keys) { if (!otherMap.ContainsKey(key)) { return(false); } if (this[key] != otherMap[key]) { return(false); } } return(true); }
public virtual bool hasEntryWithEqualKeyValuePairs(JDFAttributeMap attmap) { bool bEquals = false; for (int i = 0; i < Count; i++) { // if its the same object...ne further action needed if (attmap == this[i]) { return(true); } // reset for every entry bEquals = false; JDFAttributeMap map = this[i]; // only check if both have the same size if (map.Count == attmap.Count) { // now that we found a entry with same entry counter set // this to true. A single wrong entry will set it to false and // break. If bEquals is still true after all checks, we found // the map bEquals = true; IEnumerator <string> it = map.getKeyIterator(); while (it.MoveNext()) { string key = it.Current; if (!attmap.ContainsKey(key)) { bEquals = false; break; } string value1 = map.get(key); string value2 = attmap.get(key); if (!value1.Equals(value2)) { bEquals = false; break; } } // if bEquals is still true we found a matching map if (bEquals) { return(bEquals); } } } return(bEquals); }