public static void TestArrayRAM(int amount, int step, int seed, Action <Array, Array> algorithm) { // ReSharper disable once PossibleNullReferenceException var title = " " + algorithm.Method.DeclaringType.Name + ": Array in RAM"; Console.WriteLine(new string('_', 119)); Console.WriteLine("{0,-34}{1,13}{2,14}{3,10}{4,16}{5,10}{6,22}", title, " Progress", "Current", "Total", "Comparisons", "Swaps", "Elapsed time (ms)"); for (var i = 0; i < RunCount; i++) { ComparisonCount = 0; SwapCount = 0; var sample = new ArrayRAM(amount, seed); var count = new ArrayRAM(sample.GetMaxValue() + 1, 0); _stopwatch = Stopwatch.StartNew(); algorithm(sample, count); _stopwatch.Stop(); //DrawTextProgressBar(amount, amount); Console.WriteLine(); LogResults(title, amount); //sample.Print(); amount *= step; } }
public LinkedListDisk(string fileName, int count, int seed) { Count = count; var data = new ArrayRAM(count, seed).Data; if (File.Exists(fileName)) { File.Delete(fileName); } try { using (var writer = new BinaryWriter(File.Open(fileName, FileMode.Create))) { for (var i = 0; i < count; i++) { writer.Write(i * 12 + 4); writer.Write(data[i]); } writer.Write(count * 12 + 4); } } catch (IOException ex) { Console.WriteLine(ex.ToString()); } }