public static void MainTest(string[] args) { TextInput input = new TextInput(args[0]); int[] whitelist = input.ReadAllInts(); input.Close(); // sort the array Array.Sort(whitelist); TextInput StdIn = new TextInput(); while (!StdIn.IsEmpty) { int key = StdIn.ReadInt(); if (BinarySearch.IndexOf(whitelist, key) == -1) { Console.WriteLine(key); } } }
public static void MainTest(string[] args) { TextInput input = new TextInput(args[0]); int[] white = input.ReadAllInts(); input.Close(); // remove duplicates, if any, so the ctor below will not throw an exception white = OrderHelper.RemoveDuplicates(white); StaticSETofInts set = new StaticSETofInts(white); TextInput StdIn = new TextInput(); // Read key, print if not in whitelist. while (!StdIn.IsEmpty) { int key = StdIn.ReadInt(); if (!set.Contains(key)) { Console.WriteLine(key); } } }