public bool ContentEquals(RangeDictionary <TKey, TValue> other, IEqualityComparer <TValue> valueEqualityComparer = null) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (this.items.Count != other.items.Count) { return(false); } if (valueEqualityComparer == null) { valueEqualityComparer = this.valueEqualityComparer; } for (var i = 0; i < this.items.Count; i++) { var x = this.items[i]; var y = other.items[i]; if (!x.Key.Equals(y.Key) || !valueEqualityComparer.Equals(x.Value, y.Value)) { return(false); } } return(true); }
public bool Equals(RangeDictionary <TKey, TValue> x, RangeDictionary <TKey, TValue> y) { if (ReferenceEquals(x, y)) { return(true); } if ((x == null) || (y == null)) { return(false); } return(x.ContentEquals(y, this.ValueComparer)); }
public int GetHashCode(RangeDictionary <TKey, TValue> obj) { var valueEqualityComparer = this.ValueComparer ?? obj.ValueComparer; return(obj.GetSamples(10).Aggregate(397, (hash, item) => unchecked (hash * 3 + item.Key.From.GetHashCode() + item.Key.To.GetHashCode() + valueEqualityComparer.GetHashCode(item.Value)))); }
public VirtualDictionary(RangeDictionary <TKey, TValue> owner) { this.owner = owner; }