public IStrictSet <T> Intersect(IStrictSet <T> other) { other.ValidateNotNull("The set is null!"); var itemArray = new T[Count]; var index = 0; foreach (var item in Items) { if (!other.Contains(item)) { itemArray[index++] = item; } } foreach (var item in itemArray) { if (item == null) { break; } Remove(item); } return(this); }
public IStrictSet <T> Differ(IStrictSet <T> other) { other.ValidateNotNull("The set is null!"); foreach (var item in other) { if (Contains(item)) { Remove(item); } } return(this); }
public IStrictSet <T> Union(IStrictSet <T> other) { other.ValidateNotNull("The set is null!"); foreach (var item in other) { if (!Contains(item)) { Add(item); } } return(this); }
public bool IsSubsetOf(IStrictSet <T> other) { other.ValidateNotNull("The set is null!"); var isSubset = true; foreach (var item in Items) { if (!other.Contains(item)) { isSubset = false; break; } } return(isSubset); }
public bool IsDisjointWith(IStrictSet <T> other) { other.ValidateNotNull("The set is null!"); var disjoint = true; foreach (var item in other) { if (Contains(item)) { disjoint = false; break; } } return(disjoint); }
public bool IsEqualWith(IStrictSet <T> other) { other.ValidateNotNull("the set is null!"); return(other.IsSubsetOf(this) && IsSubsetOf(other)); }