public override bool Equals(object obj) { if (obj == null) { return(false); } if (this == obj) { return(true); } MatchingCacheKey other = (MatchingCacheKey)obj; int length = mTags.Length; if (length != other.mTags.Length) { return(false); } for (int i = 0; i < length; i++) { Tag t1 = mTags[i]; Tag t2 = other.mTags[i]; if (!(t1 == t2 || (Utils.Equals(t1.key, t2.key) && Utils.Equals(t1.value, t2.value)))) { return(false); } } return(true); }
/// <summary> /// set temporary values for comparison /// </summary> internal virtual bool set(TagSet tags, MatchingCacheKey compare) { int numTags = tags.size(); /* Test if tags are equal to previous query */ if (compare != null && numTags == compare.mTags.Length) { int i = 0; for (; i < numTags; i++) { Tag t1 = tags.get(i); Tag t2 = compare.mTags[i]; if (!(t1 == t2 || (Utils.Equals(t1.key, t2.key) && Utils.Equals(t1.value, t2.value)))) { break; } } if (i == numTags) { return(true); } } /* Clone tags as they belong to TileDataSource. * Also needed for comparison if previous tags * were equal. */ mTags = new Tag[numTags]; int result = 7; for (int i = 0; i < numTags; i++) { Tag t = tags.get(i); result = 31 * result + t.GetHashCode(); mTags[i] = t; } mHash = 31 * result; return(false); }