Пример #1
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.SetEquals" />.
        /// </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}.SetEquals"/>.</returns>
        /// <remarks>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd412096(v=vs.110).aspx" />;
        /// Determines whether the current set and the specified collection contain the same elements.
        /// </remarks>
        public static bool SetEquals <T>(ISet <T> source, IEnumerable <T> other, IEqualityComparer <T> comparer)
        {
            Contracts.Requires.That(source != null);
            Contracts.Requires.That(comparer != null);
            ISetContracts.SetEquals(other);

            return(SetEquals(source, other as HashSet <T> ?? new HashSet <T>(other, comparer)));
        }
Пример #2
0
        /// <summary>
        /// Provides an implementation of <see cref="ISet{T}.SetEquals"/>.
        /// </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}.SetEquals"/>.</returns>
        /// <remarks>
        /// From <see href="https://msdn.microsoft.com/en-us/library/dd412096(v=vs.110).aspx"/>;
        /// Determines whether the current set and the specified collection contain the same elements.
        /// </remarks>
        public static bool SetEquals <T>(ISet <T> source, HashSet <T> other)
        {
            Contracts.Requires.That(source != null);
            ISetContracts.SetEquals(other);

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

            return(other.SetEquals(source));
        }
Пример #3
0
        /// <inheritdoc />
        public bool SetEquals(IEnumerable <IDisposable> other)
        {
            ISetContracts.SetEquals(other);

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