void IMyList.GetMiddleElem(int count, middleObject midObj) { for (int i = 0; i < count; i++) { var result = array.IndexOf(midObj); } }
static void checkCollection(IMyList collection, int count) { middleObject middleObject = new middleObject(); Console.WriteLine("Check collection - " + collection.GetName()); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); collection.AddEnd(count); stopWatch.Stop(); Console.WriteLine("Time spent on the addition {0} objects to the end - {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.AddBegin(count); stopWatch.Stop(); Console.WriteLine("Time spent on the addition {0} objects to the top - {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.AddMiddle(count); stopWatch.Stop(); Console.WriteLine("Time spent on the addition {0} objects to the middle - {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.DeleteEnd(count); stopWatch.Stop(); Console.WriteLine("Time spent on the removal {0} objects of the end of Collection- {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.DeleteMiddle(count); stopWatch.Stop(); Console.WriteLine("Time spent on the removal {0} objects of the middle of collection- {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.DeleteBegin(count); stopWatch.Stop(); Console.WriteLine("Time spent on the removal {0} objects of the top of collection- {1} ms", count, stopWatch.ElapsedMilliseconds); stopWatch.Restart(); collection.GetMiddleElem(count, middleObject); stopWatch.Stop(); Console.WriteLine("Time spent on the getting {0} objects from the middle of collection- {1} ms", count, stopWatch.ElapsedMilliseconds); Console.WriteLine("==============================================================================================="); }
void IMyList.GetMiddleElem(int count, middleObject midObj) { for (int i = 0; i < count; i++) { var result = linked.Find(midObj); } }