public SimpleSet <T> Difference(SimpleSet <T> set) { return(new SimpleSet <T>(items.Except(set.items))); //var result = new SimpleSet<T>(items); //foreach (var item in set.items) //{ // result.Remove(item); //} //return result; }
public SimpleSet <T> Union(SimpleSet <T> set) { return(new SimpleSet <T>(items.Union(set.items))); //var result = new SimpleSet<T>(); //foreach (var item in items) //{ // result.Add(item); //} //foreach (var item in set.items) //{ // result.Add(item); //} //return result; }
public bool Subset(SimpleSet <T> set) { //return set.items.All(i => items.Contains(i)); foreach (var item in set.items) { if (items.Contains(item)) { continue; } else { return(false); } } return(true); }
public SimpleSet <T> Intersection(SimpleSet <T> set) { return(new SimpleSet <T>(items.Intersect(set.items))); //var result = new SimpleSet<T>(); //foreach (var item1 in items) //{ // foreach(var item2 in set.items) // { // if(item1.Equals(item2)) // { // result.Add(item1); // break; // } // } //} //return result; }
public SimpleSet <T> SymmetricDifference(SimpleSet <T> set) { return(new SimpleSet <T>(items.Except(set.items).Union(set.items.Except(items)))); }