Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        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))));
        }
Exemplo n.º 4
0
 public VirtualDictionary(RangeDictionary <TKey, TValue> owner)
 {
     this.owner = owner;
 }