예제 #1
0
        private static void displayIntersect(IIntersecter intersecter, IGenerator generator, string text, int?count = null, int?comparisons = null)
        {
            intersecter.Intersect(generator.Array1, generator.Array2);

            Console.WriteLine($"{text} intersecter:");
            colorWrite($"Comparisons: {intersecter.Comparisons}", () =>
            {
                if (comparisons == null)
                {
                    return(ConsoleColor.White);
                }
                switch (intersecter.Comparisons.CompareTo(comparisons.Value))
                {
                case -1:
                    return(ConsoleColor.Green);

                default:
                case 0:
                    return(ConsoleColor.White);

                case 1:
                    return(ConsoleColor.Red);
                }
            });
            if (comparisons == null)
            {
                Console.WriteLine();
            }
            else
            {
                var perc = 100 * (double)intersecter.Comparisons / comparisons.Value;
                Console.WriteLine($" ({perc:#.00}%)");
            }
            //Console.WriteLine($"Time: {intersecter.Time.TotalMilliseconds}");
            colorWrite($"Count: {intersecter.Result.Count}\r\n", () => count == null || intersecter.Result.Count == count ? ConsoleColor.White : ConsoleColor.Red);
        }