示例#1
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.IsSupersetOf"/>.
        /// </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}.IsSupersetOf"/>.</returns>
        /// <remarks>
        /// <para>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd382354(v=vs.110).aspx"/>;
        /// Determines whether the current set is a superset of a specified collection.
        /// </para><para>
        /// If other contains the same elements as the current set, the current set is still considered
        /// a superset of other.
        /// </para><para>
        /// This method always returns false if the current set has fewer elements than other.
        /// </para>
        /// </remarks>
        public static bool IsSupersetOf <T>(ISet <T> source, IEnumerable <T> other)
        {
            Contracts.Requires.That(source != null);
            ISetContracts.IsSupersetOf(other);

            ICollection <T> otherCollection = other as ICollection <T>;

            if (otherCollection != null && source.Count < otherCollection.Count)
            {
                return(false);
            }

            return(other.All(source.Contains));
        }
示例#2
0
        /// <inheritdoc />
        public bool IsSupersetOf(IEnumerable <IDisposable> other)
        {
            ISetContracts.IsSupersetOf(other);

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