Re: Fast enumeration
Re: Fast enumeration
- Subject: Re: Fast enumeration
- From: Quincey Morris <email@hidden>
- Date: Thu, 22 Jul 2010 16:42:24 -0700
On Jul 22, 2010, at 16:37, Graham Cox wrote:
> On 23/07/2010, at 9:28 AM, Jonathon Kuo wrote:
>
>> If I use this to go backward through the array:
>>
>> for (_id in [array reverseObjectEnumerator]) {
>> }
>>
>> ...is it still considered 'fast' enumeration?
>
>
> Yes, NSEnumerator conforms to the fast enumeration protocol.
... although we don't know know (AFAIK) whether the NSEnumerator implementation is really "fast". (It could implement the protocol, but still retrieve objects one at a time with 'nextObject' internally. That would have similar performance to using NSEnumerator the old way, I think.)
My guess is that the NSEnumerator class has a generic implementation that isn't any faster, but that specific enumerators (such as NSArray, NSSet, NSDictionary, etc) really use the underying collection's fast implementation._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden