/// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than obj. Zero This instance is equal to obj. Greater than zero This instance is greater than obj. /// </returns> /// <exception cref="T:System.ArgumentException">obj is not the same type as this instance. </exception> public int CompareTo(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } if (this.GetType() == obj.GetType()) { PascalSet set = obj as PascalSet; return(this.Count.CompareTo(set.Count)); } else { return(this.GetType().FullName.CompareTo(obj.GetType().FullName)); } }
/// <summary> /// Determines whether this set is a superset of the specified set. /// </summary> /// <param name="set">The set to be compared against.</param> /// <returns> /// <c>true</c> if this set is a superset of the specified set; otherwise, <c>false</c>. /// </returns> public bool IsSupersetOf(PascalSet set) { if (set == null) { throw new ArgumentNullException("set"); } CheckIfUniverseTheSame(set); for (int i = 0; i < data.Length; i++) { if (set.data[i]) { if (!data[i]) { return(false); } } } return(true); }
/// <summary> /// Determines whether the specified set is equal to this one. /// </summary> /// <param name="set">The set.</param> /// <returns> /// <c>true</c> if the specified set is equal this this one; otherwise, <c>false</c>. /// </returns> public bool IsEqual(PascalSet set) { if (set == null) { throw new ArgumentNullException("set"); } if (!IsUniverseTheSame(set)) { return(false); } else { for (int i = 0; i < data.Length; i++) { if (data[i] != set.data[i]) { return(false); } } } return(true); }
/// <summary> /// Determines whether [is universe the same] [the specified set]. /// </summary> /// <param name="set">The set.</param> /// <returns> /// <c>true</c> if [is universe the same] [the specified set]; otherwise, <c>false</c>. /// </returns> private bool IsUniverseTheSame(PascalSet set) { return ((set.lowerBound == this.lowerBound) && (set.upperBound == this.upperBound)); }