public static void checkListDeleteFirstSpeed(int quantity) { ArrayList testAL = createArrayList(quantity); Console.WriteLine("Procesing (with ArrayList). Please wait... \n"); stopWatchAL.Restart(); testAL.RemoveAt(0); stopWatchAL.Stop(); tsAL = stopWatchAL.Elapsed; string elapsedTimeAL = String.Format("{0:00}.{1:000}", tsAL.Seconds, tsAL.Milliseconds); ArrayListUtils.printReportAL(elapsedTimeAL); }
public static void checkListInsertAtBeginningSpeed(int quantity, int newQuantity) { ArrayList testAL = createArrayList(quantity); Console.WriteLine("Procesing (with ArrayList). Please wait... \n"); stopWatchAL.Restart(); for (int i = 0; i < newQuantity; i++) { var a = new Temp(i, i, i, i); testAL.Insert(i, a); } stopWatchAL.Stop(); tsAL = stopWatchAL.Elapsed; string elapsedTimeAL = String.Format("{0:00}.{1:000}", tsAL.Seconds, tsAL.Milliseconds); ArrayListUtils.printReportAL(elapsedTimeAL); }
public static void listFindObjectSpeed(int quantity, int value) { ArrayList testAL = createArrayList(quantity); Console.WriteLine("Procesing (with ArrayList). Please wait... \n"); stopWatchAL.Restart(); foreach (Temp t in testAL) { if (t.i1 == value) { var index = testAL.IndexOf(t); break; } } stopWatchAL.Stop(); tsAL = stopWatchAL.Elapsed; string elapsedTimeAL = String.Format("{0:00}.{1:000}", tsAL.Seconds, tsAL.Milliseconds); ArrayListUtils.printReportAL(elapsedTimeAL); }
static void Main(string[] args) { int quantity; int newQuantity; int value; bool loop = true; while (loop) { Utils.printMenu(); string menuSelector = Console.ReadLine(); Console.Write("\n"); switch (menuSelector) { case "1": quantity = Utils.setNewQuantity(); if (quantity != 0) { ArrayListUtils.checkEmptyListAddSpeed(quantity); LinkedListUtils.checkEmptyListAddSpeed(quantity); } break; case "2": quantity = Utils.setQuantity(); newQuantity = Utils.setNewQuantity(); if (quantity != 0 && newQuantity != 0) { ArrayListUtils.checkListInsertAtMiddleSpeed(quantity, newQuantity); LinkedListUtils.checkListInsertAtMiddleSpeed(quantity, newQuantity); } break; case "3": quantity = Utils.setQuantity(); newQuantity = Utils.setNewQuantity(); if (quantity != 0 && newQuantity != 0) { ArrayListUtils.checkListInsertAtBeginningSpeed(quantity, newQuantity); LinkedListUtils.checkListInsertAtBeginningSpeed(quantity, newQuantity); } break; case "4": quantity = Utils.setQuantity(); value = Utils.setValue(); if (quantity != 0 && value != 0) { ArrayListUtils.listFindObjectSpeed(quantity, value); LinkedListUtils.listFindObjectSpeed(quantity, value); } break; case "5": quantity = Utils.setQuantity(); if (quantity != 0) { ArrayListUtils.checkListDeleteLastSpeed(quantity); LinkedListUtils.checkListDeleteLastSpeed(quantity); } break; case "6": quantity = Utils.setQuantity(); if (quantity != 0) { ArrayListUtils.checkListDeleteMidSpeed(quantity); LinkedListUtils.checkListDeleteMidSpeed(quantity); } break; case "7": quantity = Utils.setQuantity(); if (quantity != 0) { ArrayListUtils.checkListDeleteFirstSpeed(quantity); LinkedListUtils.checkListDeleteFirstSpeed(quantity); } break; case "0": loop = false; break; default: Console.Write("Illegal input"); break; } } }