public static CustomSet <T> Union(CustomSet <T> set1, CustomSet <T> set2) { if (set1 == null || set2 == null) { throw new ArgumentNullException(); } CustomSet <T> result = new CustomSet <T>(set1); for (int i = 0; i < set2.Count; i++) { result.Add(set2.Collection[i]); } return(result); }
public override bool Equals(object obj) { if (!(obj is CustomSet <T>)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } CustomSet <T> customSetObj = (CustomSet <T>)obj; if (Count != customSetObj.Count) { return(false); } return(!customSetObj.Where((t, i) => !Collection.Contains(customSetObj.Collection[i])).Any()); //for (int i = 0; i < customSetObj.Count; i++) // if (!Collection.Contains(customSetObj.Collection[i])) // return false; //return true; }
protected bool Equals(CustomSet <T> other) => Equals(Collection, other.Collection);
//public CustomSet(T[] elements) : this(elements.Length + 1) //{ // Collection = new CustomCollection<T>(elements); //} public CustomSet(CustomSet <T> set) { Collection = new CustomCollection <T>(set.Collection); }