// Needed for NET40 #if !NET_4_6 using System; using System.Collections.Generic; using LinqInternal.Core; namespace LinqInternal.Collections { [Serializable] [System.Diagnostics.DebuggerNonUserCode] internal partial class ProgressiveSet : ProgressiveCollection, ISet { // Note: these constructors uses ExtendedSet because HashSet is not an ISet in .NET 3.5 and base class needs an ISet public ProgressiveSet(IEnumerable wrapped) : this(wrapped, new ExtendedSet(), null) { // Empty } public ProgressiveSet(Progressor wrapped) : this(wrapped, new ExtendedSet(), null) { // Empty } public ProgressiveSet(IEnumerable wrapped, IEqualityComparer comparer) : this(wrapped, new ExtendedSet(comparer), null) { // Empty } public ProgressiveSet(Progressor wrapped, IEqualityComparer comparer) : this(wrapped, new ExtendedSet(comparer), null) { // Empty } protected ProgressiveSet(IEnumerable wrapped, ISet cache, IEqualityComparer comparer) : this(Check.NotNullArgument(wrapped, "wrapped").GetEnumerator(), cache, comparer) { // Empty } protected ProgressiveSet(Progressor wrapped, ISet cache, IEqualityComparer comparer) : base ( (out T value) => { again: if (wrapped.TryTake(out value)) { if (cache.Contains(value)) { goto again; } return true; } else { return false; } }, cache, comparer ) { // Empty } private ProgressiveSet(IEnumerator enumerator, ISet cache, IEqualityComparer comparer) : base ( (out T value) => { again: if (enumerator.MoveNext()) { value = enumerator.Current; if (cache.Contains(value)) { goto again; } return true; } else { enumerator.Dispose(); value = default(T); return false; } }, cache, comparer ) { // Empty } bool ICollection.IsReadOnly { get { return true; } } public bool IsProperSubsetOf(IEnumerable other) { return Extensions.IsProperSubsetOf(this, other); } public bool IsProperSupersetOf(IEnumerable other) { return Extensions.IsProperSupersetOf(this, other); } public bool IsSubsetOf(IEnumerable other) { return Extensions.IsSubsetOf(this, other); } public bool IsSupersetOf(IEnumerable other) { return Extensions.IsSupersetOf(this, other); } public bool Overlaps(IEnumerable other) { return Extensions.Overlaps(this, other); } public bool SetEquals(IEnumerable other) { return Extensions.SetEquals(this, other); } void ICollection.Add(T item) { throw new NotSupportedException(); } bool ISet.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } void ISet.ExceptWith(IEnumerable other) { throw new NotSupportedException(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } void ISet.IntersectWith(IEnumerable other) { throw new NotSupportedException(); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } void ISet.SymmetricExceptWith(IEnumerable other) { throw new NotSupportedException(); } void ISet.UnionWith(IEnumerable other) { throw new NotSupportedException(); } } } #endif