AFAIU, LinkedList.get(N) requires traversing the list to position N on every call [O(n^2)], so usage of an iteratoe is much cheaper on this case as there is no array behind the scenes.
Jose Alberto > -----Original Message----- > From: Kev Jackson [mailto:[EMAIL PROTECTED] > Sent: 28 February 2005 11:03 > To: Ant Developers List > Subject: Massively OT, 'Closures in Java' [was Re: AW: > [Patch] modifiedselector, style, remove unused code, slightly > more lazy DigestAlgorithm.getValue (now with added source code -doh!)] > > > Jose Alberto Fernandez wrote: > > >Just one comment on your ClosureUtils.map() method. > > > >Although this code may be very good for ArrayList, I think > >it will behave quite bad for LinkList arguments where > >the cost of List.get(i) is quite expensive. > > > > > > > When I read this, I thought "Doh! you're right none-sequential List > access is expensive", but I just rewrote the tests using a LinkedList > and the time is identical. Maybe it's because the > ClosureUtils requires > a List interface not an ArrayList object, and as such it treats > everything as simply something that implements List and uses > the lowest > common denominator, or maybe it's because my test data is trivial > [shrug]. Still interesting code-doodle anyway. Thanks for > the feedback ;) > > Kev > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]