J
John A Grandy
Is there a performance difference between forward iteration and reverse
iteration through a List<string> ?
for ( i = 0; i < myList.Count; i++ )
{
// do work, such as forward iterate through a subset of myList ...
}
vs
for ( j = myList.Count - 1 ; j >= 0; j-- )
{
// do work, such as reverse iterate through a subset of myList ...
}
In other words, is there a performance advantage to pre-sorting a list so
that forward iteration may be used in implementing an algorithm ?
iteration through a List<string> ?
for ( i = 0; i < myList.Count; i++ )
{
// do work, such as forward iterate through a subset of myList ...
}
vs
for ( j = myList.Count - 1 ; j >= 0; j-- )
{
// do work, such as reverse iterate through a subset of myList ...
}
In other words, is there a performance advantage to pre-sorting a list so
that forward iteration may be used in implementing an algorithm ?