private static void FirstTest() { ArrayBasedVector <int> arrayBasedVector = new ArrayBasedVector <int>(); arrayBasedVector.InsertAtRank(0, 7); arrayBasedVector.InsertAtRank(1, 3); arrayBasedVector.InsertAtRank(2, 2); arrayBasedVector.InsertAtRank(3, 9); arrayBasedVector.InsertAtRank(4, 8); Console.WriteLine(arrayBasedVector); arrayBasedVector.InsertAtRank(2, 5); Console.WriteLine(arrayBasedVector); arrayBasedVector.RemoveAtRank(2); arrayBasedVector.ReplaceAtRank(4, 0); Console.WriteLine(arrayBasedVector); List <int> list = new List <int>(); list.Add(3); }
private static double TimeMethodInsertAtRankZero(int problemSize, int repetitions = 5) { Stopwatch sw = new Stopwatch(); List <long> results = new List <long>(repetitions); #region setup // Build an array based vector that is as large as the problem size ArrayBasedVector <int> arrayBasedVector = new ArrayBasedVector <int>(); for (int i = 0; i < problemSize; i++) { arrayBasedVector.Append(1); } #endregion for (int r = 0; r < repetitions; r++) { // usually: // call method with the given problem size once... sw.Restart(); arrayBasedVector.InsertAtRank(0, 1); // the problem size happens because the arrayBasedVector is large (it has a number of elements equal to the Problem Size) sw.Stop(); results.Add(sw.ElapsedTicks); } return(results.Average()); }