I have a homework assignment where I must constructively and destructively reverse an array list and time it for varying lengths of the list. My Arraylist does update each time I run it but it doesn't seem to register in these methods as I'm not getting values for my timing and can't seem to find my errors.
My code so far is as follows.
public ArrayList ConstructiveReverseDeveloped()
{
ArrayList Temp = new ArrayList();
for (int i = Developed.Count - 1; i >= 0; i--)
{
Apps cur = (Apps)Developed[i];
Temp.Add(cur);
}
return Temp;
}
public void TimingConstructive()
{
DateTime startTime;
TimeSpan endTime;
startTime = DateTime.Now;
ConstructiveReverseDeveloped();
endTime = DateTime.Now.Subtract(startTime);
Console.WriteLine("---------------------------------------------------------");
Console.WriteLine("Time taken for Constructive Reverse of Developed : {0}", endTime);
}
public void DestructiveReverseDeveloped()
{
//ArrayList x = cloneDeveloped();
for (int i = Developed.Count - 1; i >= 0; i--)
{
Apps cur = (Apps)Developed[i];
Developed.RemoveAt(i);
Developed.Add(cur);
}
}
public void TimingDestructive()
{
DateTime startTime;
TimeSpan endTime;
startTime = DateTime.Now;
DestructiveReverseDeveloped();
endTime = DateTime.Now.Subtract(startTime);
Console.WriteLine("Time taken for Destructive Reverse of Developed : {0}",endTime.ToString());
Console.WriteLine("---------------------------------------------------------");
}
Can you guys please point me in the right direction as to why I'm not getting timing values? I don't want the exact answers but rather just help in understanding.
Thanks