DataSharp/Mathematics/SetHelper.cs
/// <summary>
/// Returns the complement of the subset in the complete set.
/// </summary>
/// <typeparam name="T">The type of elements in the set.</typeparam>
/// <param name="set">The complete set.</param>
/// <param name="subset">A subset of the complete set.</param>
/// <returns>The complement of the subset in the complete set.</returns>
Returns the complement of the subset in the complete set.
Returns the complement of the subset in the complete set .
public static ISet<T> GetComplement<T>(ISet<T> set, ISet<T> subset)
        {
            if (!set.IsSupersetOf(subset))
                throw new ArgumentException("Errors occured in input sets.");
            SortedSet<T> complement = new SortedSet<T>(set);
            complement.ExceptWith(subset);
            return complement;
        }
public static ISet < T > GetComplement < T > ( ISet < T > set , ISet < T > subset ) { if ( ! set . IsSupersetOf ( subset ) ) throw new ArgumentException ( " " ) ; SortedSet < T > complement = new SortedSet < T > ( set ) ; complement . ExceptWith ( subset ) ; return complement ; }
Returns the complement of the subset in the complete set.
Returns the complement of the subset in the complete set .
// Throw an exception if the input sets are not correct. // Make a copy of the complete set because the ExceptWith() method will change the set itself. // Remove all the element in the given subset from the complete set so that the complement will be the set of elements remained. // Return the complete
The complement of the subset in the complete set.
The complement of the subset in the complete set .
set
ISet<T>
The complete set.
The complete set .
subset
ISet<T>
A subset of the complete set.
A subset of the complete set .
typeparam
The type of elements in the set.
The type of elements in the set .