示例#1
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.IsProperSubsetOf" />.
        /// </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}.IsProperSubsetOf" />.</returns>
        /// <remarks>
        /// <para>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd321100(v=vs.110).aspx" />;
        /// Determines whether the current set is a proper (strict) subset of a specified collection.
        /// </para>
        /// <para>
        /// If the current set is a proper subset of other, other must have at least one element that the current
        /// set does not have.
        /// </para>
        /// <para>
        /// An empty set is a proper subset of any other collection.Therefore, this method returns true if the
        /// current set is empty, unless the other parameter is also an empty set.
        /// </para>
        /// <para>
        /// This method always returns false if the current set has more or the same number of elements than other.
        /// </para></remarks>
        public static bool IsProperSubsetOf <T>(ISet <T> source, IEnumerable <T> other, IEqualityComparer <T> comparer)
        {
            Contracts.Requires.That(source != null);
            Contracts.Requires.That(comparer != null);
            ISetContracts.IsProperSubsetOf(other);

            return(IsProperSubsetOf(source, other as HashSet <T> ?? new HashSet <T>(other, comparer)));
        }
示例#2
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.IsProperSubsetOf"/>.
        /// </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}.IsProperSubsetOf"/>.</returns>
        /// <remarks>
        /// <para>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd321100(v=vs.110).aspx"/>;
        /// Determines whether the current set is a proper (strict) subset of a specified collection.
        /// </para><para>
        /// If the current set is a proper subset of other, other must have at least one element that the current
        /// set does not have.
        /// </para><para>
        /// An empty set is a proper subset of any other collection.Therefore, this method returns true if the
        /// current set is empty, unless the other parameter is also an empty set.
        /// </para><para>
        /// This method always returns false if the current set has more or the same number of elements than other.
        /// </para>
        /// </remarks>
        public static bool IsProperSubsetOf <T>(ISet <T> source, HashSet <T> other)
        {
            Contracts.Requires.That(source != null);
            ISetContracts.IsProperSubsetOf(other);

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

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

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