public bool IsSubsetOf(IEnumerable <T> other) { if (this.count == 0) { return(true); } HashCollection <T> collection = GetHashCollectionWithSameEC(other); if (collection != null) { if (this.count > collection.Count) { return(false); } foreach (T item in this) { if (!collection.Contains(item)) { return(false); } } return(true); } IndexedSetHelper <T> setHelper = new IndexedSetHelper <T>(this, lastIndex); return(setHelper.IsSubsetOf(other)); }
public void IntersectWith(IEnumerable <T> other) { if (count > 0) { if (IsWellKnownCollection(other, out int num)) { if (num > 0) { this.Clear(); return; } HashCollection <T> collection = GetHashCollectionWithSameEC(other); if (collection != null) { for (int i = 0; i < lastIndex; i++) { if (entries[i].hashCode >= 0) { T obj = entries[i].item; if (!collection.Contains(obj)) { this.Remove(obj); } } } return; } } BitArray bits = new BitArray(Count); foreach (T item in other) { int index = IndexOf(item); if (index >= 0) { bits[index] = true; } } for (int j = 0; j < lastIndex; j++) { if ((entries[j].hashCode >= 0) && (bits[j])) { Remove(entries[j].item); } } } }