/// <summary> /// Main method for the sets lab program /// </summary> /// <param name="args">Console arguments to pass to the program</param> public static void Main(string[] args) { int[] intArrA = { 1, 2, 4, 6, 8, 9, 6, 5, 4, 3 }; int[] intArrB = { 3, 6, 8, 2, 1, 1, 11, 3, 455, 6, 44, 2 }; SetsLab setA = new SetsLab(intArrA); SetsLab setB = new SetsLab(intArrB); setA.UnionSet(setB.GetIntSet()); }
/// <summary> /// Iterates through the larger array and determines which elements belong to either /// </summary> /// <param name="setToUnionWith">Integer array to be unioned with this. array</param> /// <returns>A SetsLab variable containing the unioned set</returns> public SetsLab UnionSet(int[] setToUnionWith) { int k; int setLength = setToUnionWith.Length; SetsLab returnSet = new SetsLab(); for (k = 0; k < setLength; k++) { if (this.GetIntSet(k) == setToUnionWith[k]) { returnSet.Insert(this.GetIntSet(k)); } else if (this.GetIntSet(k) != setToUnionWith[k]) { returnSet.Insert(setToUnionWith[k]); } } Console.WriteLine("Unioned set = {0}", returnSet); return(returnSet); }
/// <summary> /// Iterates through the larger array and determines which elements belong to either /// </summary> /// <param name="setToUnionWith">Integer array to be unioned with this. array</param> /// <returns>A SetsLab variable containing the unioned set</returns> public SetsLab UnionSet(int[] setToUnionWith) { int k; int setLength = setToUnionWith.Length; SetsLab returnSet = new SetsLab(); for (k = 0; k < setLength; k++) { if (this.GetIntSet(k) == setToUnionWith[k]) { returnSet.Insert(this.GetIntSet(k)); } else if (this.GetIntSet(k) != setToUnionWith[k]) { returnSet.Insert(setToUnionWith[k]); } } Console.WriteLine("Unioned set = {0}", returnSet); return returnSet; }