Example #1
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.IsProperSupersetOf"/>.
        /// </summary>
        /// <typeparam name="T">The type of values in the collections.</typeparam>
        /// <param name="source">The source collection that is implementing <see cref="ISet{T}"/>.</param>
        /// <param name="other">The other enumerable.</param>
        /// <param name="comparer">The comparer.</param>
        /// <returns>The result of <see cref="ISet{T}.IsProperSupersetOf"/>.</returns>
        /// <remarks>
        /// <para>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd411711(v=vs.110).aspx"/>;
        /// Determines whether the current set is a proper (strict) superset of a specified collection.
        /// </para><para>
        /// If the current set is a proper superset of other, the current set must have at least one element
        /// that other does not have.
        /// </para><para>
        /// An empty set is a proper superset of any other collection.Therefore, this method returns true if
        /// the collection represented by the other parameter is empty, unless the current set is also empty.
        /// </para><para>
        /// This method always returns false if the number of elements in the current set is less than or equal
        /// to the number of elements in other.
        /// </para>
        /// </remarks>
        public static bool IsProperSupersetOf <T>(ISet <T> source, IEnumerable <T> other, IEqualityComparer <T> comparer)
        {
            Contracts.Requires.That(source != null);
            Contracts.Requires.That(comparer != null);
            ISetContracts.IsProperSupersetOf(other);

            return(IsProperSupersetOf(source, other as HashSet <T> ?? new HashSet <T>(other, comparer)));
        }
Example #2
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.IsProperSupersetOf"/>.
        /// </summary>
        /// <typeparam name="T">The type of values in the collections.</typeparam>
        /// <param name="source">The source collection that is implementing <see cref="ISet{T}"/>.</param>
        /// <param name="other">The other enumerable.</param>
        /// <returns>The result of <see cref="ISet{T}.IsProperSupersetOf"/>.</returns>
        /// <remarks>
        /// <para>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd411711(v=vs.110).aspx"/>;
        /// Determines whether the current set is a proper (strict) superset of a specified collection.
        /// </para><para>
        /// If the current set is a proper superset of other, the current set must have at least one element
        /// that other does not have.
        /// </para><para>
        /// An empty set is a proper superset of any other collection.Therefore, this method returns true if
        /// the collection represented by the other parameter is empty, unless the current set is also empty.
        /// </para><para>
        /// This method always returns false if the number of elements in the current set is less than or equal
        /// to the number of elements in other.
        /// </para>
        /// </remarks>
        public static bool IsProperSupersetOf <T>(ISet <T> source, HashSet <T> other)
        {
            Contracts.Requires.That(source != null);
            ISetContracts.IsProperSupersetOf(other);

            if (source.Count <= other.Count)
            {
                return(false);
            }

            return(other.IsProperSubsetOf(source));
        }
Example #3
0
        /// <inheritdoc />
        public bool IsProperSupersetOf(IEnumerable <IDisposable> other)
        {
            ISetContracts.IsProperSupersetOf(other);

            return(this.disposables.IsProperSupersetOf(other));
        }