public bool Equals(IDictionary <FA <TInput, TAccept>, ICollection <TInput> > lhs, IDictionary <FA <TInput, TAccept>, ICollection <TInput> > rhs) { if (lhs.Count != rhs.Count) { return(false); } if (ReferenceEquals(lhs, rhs)) { return(true); } else if (ReferenceEquals(null, lhs) || ReferenceEquals(null, rhs)) { return(false); } using (var xe = lhs.GetEnumerator()) using (var ye = rhs.GetEnumerator()) while (xe.MoveNext() && ye.MoveNext()) { if (xe.Current.Key != ye.Current.Key) { return(false); } if (!CollectionUtility.Equals(xe.Current.Value, ye.Current.Value)) { return(false); } } return(true); }
/// <summary> /// Indicates whether the CFG is exactly equivelant to the specified CFG /// </summary> /// <param name="rhs">The CFG to compare</param> /// <returns>True if the CFGs are equal, otherwise false.</returns> public bool Equals(Cfg rhs) { if (!CollectionUtility.Equals(this.Rules, rhs.Rules)) { return(false); } if (AttributeSets.Count != rhs.AttributeSets.Count) { return(false); } foreach (var attrs in AttributeSets) { AttributeSet d; if (!rhs.AttributeSets.TryGetValue(attrs.Key, out d)) { if (d.Count != attrs.Value.Count) { return(false); } foreach (var attr in attrs.Value) { object o; if (!d.TryGetValue(attr.Key, out o) || !Equals(o, attr.Value)) { return(false); } } } } return(true); }
/// <summary> /// Gets a hashcode that represents this CFG /// </summary> /// <returns>A hashcode that represents this CFG</returns> public override int GetHashCode() { var result = CollectionUtility.GetHashCode(Rules); foreach (var attrs in AttributeSets) { result ^= attrs.Key.GetHashCode(); foreach (var attr in attrs.Value) { result ^= attr.Key.GetHashCode(); if (null != attr.Value) { result ^= attr.Value.GetHashCode(); } } } return(result); }
public void CopyTo(T[] array, int index) { CollectionUtility.CopyTo(_inner, array, index); }