/// <summary> /// Determines whether this set is a proper subset of the specified set. /// </summary> /// <param name="set">The set to be compared against.</param> /// <returns> /// <c>true</c> if this is a proper subset of the specified set; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="set"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="set"/> is not in the same universe as this instance.</exception> /// <example> /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\PascalSetExamples.cs" region="IsProperSubsetOf" lang="cs" title="The following example shows how to use the IsProperSubsetOf method."/> /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\PascalSetExamples.vb" region="IsProperSubsetOf" lang="vbnet" title="The following example shows how to use the IsProperSubsetOf method."/> /// </example> public bool IsProperSubsetOf(PascalSet set) { #region Validation Guard.ArgumentNotNull(set, "set"); CheckIfUniverseTheSame(set); #endregion // A is a proper subset of a if the b is a subset of a and a != b return(IsSubsetOf(set) && !set.IsSubsetOf(this)); }
/// <summary> /// Computes the difference between this set and the specified set. /// </summary> /// <param name="set">The set.</param> /// <returns>The result of the difference operation.</returns> /// <exception cref="ArgumentNullException"><paramref name="set"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="set"/> is not in the same universe as this instance.</exception> /// <example> /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\PascalSetExamples.cs" region="Subtract" lang="cs" title="The following example shows how to use the Subtract method."/> /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\PascalSetExamples.vb" region="Subtract" lang="vbnet" title="The following example shows how to use the Subtract method."/> /// </example> public PascalSet Subtract(PascalSet set) { #region Validation Guard.ArgumentNotNull(set, "set"); CheckIfUniverseTheSame(set); #endregion return(new PascalSet(data.Xor(set.data), lowerBound, upperBound)); }
/// <inheritdoc /> public bool Equals(PascalSet other) { if ((other == null) || (!IsUniverseTheSame(other))) { return(false); } for (var i = 0; i < data.Length; i++) { if (data[i] != other.data[i]) { return(false); } } return(true); }
/// <summary> /// Determines whether this set is a subset of the specified set. /// </summary> /// <param name="set">The set to be compared against.</param> /// <returns> /// <c>true</c> if this set is a subset of the specified set]; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="set"/> is a null reference (<c>Nothing</c> in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="set"/> is not in the same universe as this instance.</exception> /// <example> /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\PascalSetExamples.cs" region="IsSubsetOf" lang="cs" title="The following example shows how to use the IsSubsetOf method."/> /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\PascalSetExamples.vb" region="IsSubsetOf" lang="vbnet" title="The following example shows how to use the IsSubsetOf method."/> /// </example> public bool IsSubsetOf(PascalSet set) { #region Validation Guard.ArgumentNotNull(set, "set"); CheckIfUniverseTheSame(set); #endregion for (var i = 0; i < data.Length; i++) { if (data[i]) { if (!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 == lowerBound) && (set.upperBound == upperBound)); }