private static int Calculate(NODAlgorithm algorithm, params int[] array) { if (array == null) throw new ArgumentNullException(); if (array.Length == 0) throw new ArgumentException(); if (array.Length == 1) return array[0]; int result = 0; for (int i = 0; i < array.Length; i++) { result = Calculate(algorithm, result, array[i]); } return result; }
private static int Calculate(NODAlgorithm algorithm, int a, int b) { a = Math.Abs(a); b = Math.Abs(b); return algorithm(a, b); }
private static int Calculate(NODAlgorithm algorithm,int a,int b) { a = Math.Abs(a); b = Math.Abs(b); if (a == 0) return b; if (a == 1) return 1; if (b == 0) return a; if (b == 1) return 1; if (a == b) return a; return algorithm(a, b); }
private static int Calculate(NODAlgorithm algorithm, out long ticks, params int[] array) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); int result = Calculate(algorithm, array); stopwatch.Stop(); ticks = stopwatch.ElapsedTicks; return result; }
private static int Calculate(NODAlgorithm algorithm,out long ticks, int a, int b) { var sw = new Stopwatch(); sw.Start(); int result = Calculate(algorithm,a, b); sw.Stop(); ticks = sw.ElapsedTicks; return result; }