forward-iteration vs reverse-iteration
- From: "John A Grandy" <johnagrandy@g-mail-dot-com>
- Date: Sat, 24 May 2008 17:30:00 -0700
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 ?
.
- Follow-Ups:
- Re: forward-iteration vs reverse-iteration
- From: Doug Forster
- Re: forward-iteration vs reverse-iteration
- From: Arne Vajhøj
- Re: forward-iteration vs reverse-iteration
- From: Peter Duniho
- Re: forward-iteration vs reverse-iteration
- Prev by Date: Re: string.Split() performant ?
- Next by Date: Re: Encapsulation
- Previous by thread: string.Split() performant ?
- Next by thread: Re: forward-iteration vs reverse-iteration
- Index(es):
Relevant Pages
|